Ignoring our off-topic request for a plugin, the good news is: yes, this is possible. On the other hand, it is quite some work, so I will give just an outline here.
WordPress does have built-in image manipulation. The default one is Image Magick. WordPress’ image editor class, however, only offers a subset of what Image Magick is actually capable of. This means that you will have to pierce through the class and use the PHP
commands directly to do what you want.
First you will have to register an image size
add_action( 'init', 'wpse358037_register_collage_size' );
function wpse358037_register_collage_size() {
add_image_size( 'collage', 1024, 512, true );
}
Second, when a tag is created you want to set a featured image for it, composed from one or more featured images of posts with that tag. There are several ways to do this, but the handiest may be hooking into the set_object_terms
action. This fires at the end of wp_set_object_terms
, a function that is executed whenever a post taxonomy is created or updated. Assuming that you only want to update the collage image when a new post/picture has been added, this is the perfect hook to create/update the collage without putting a burden on your server. You create the collage image and attach it as metadata to the tag. Pseudocode:
add_action( 'set_object_terms', 'wpse358037_register_collage_size', 10, 6 );
function wpse358037_register_collage_size ($object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids) {
if (... some sort of condition to match only post tags ...) {
// if there are multiple tags, you may have to loop throug them
foreach ($tags as $tag) {
$images_to_be_used = ... depending on tag and you criteria make array of images
$collage_image_path = wpse358037_collage_image ($tag, $images_to_be_used);
// save the path to the resulting image as metadata to the tag
add_term_meta ($tag_ID, 'collage-image', $collage_image_path, false) ;
}
}
}
Finally you’ll have to do the actual image action for which Image Magick even has a native function called mosaic:
function wpse358037_collage_image ($tag, $images_to_be_used) {
// loop through all $images_to_be_used doing this
$collage_image[i] = new Imagick( $path_to_image);
// now you have an array of images ready to be handled by Image Magick
.. do your mosaic magic and save the result in $collage_image_final_result
// all that is left now is saving the image and return the path so it can be saved as metadata
$path = .. wherever you want to save it (upload_dir + name + '.jpg')
$collage_image_final_result->writeImage ($path);
return $path;
}
As you can see, there’s still quite a lot of development work to be done, but hopefully this outline will help you get what you want.