I have image assets that I load externally and insert programmatically. There are 3 different asset classes:
landscape, portrait, and 1:1
The default image_sizes
are creating a lot of clutter that's of no use to me. So I've disabled those and added my own custom ones.
But Wordpress is generating resized assets that fits every asset class, despite it only being relevant for 1/3rd. Since the only condition for making a resized asset seems to be exceeding a width/height threshold.
Is it possible to indicate which specific image sizes you want Wordpress to create when you insert an image asset at file_put_contents
or wp_update_attachment_metadata
, specifically for this one asset, instead of dictating the sizes that should be created globally? Such that we only create the extra sizes relevant to landscape assets when we know we're insert landscape assets?
Or alternatively, can you create a custom image_size that factors in aspect ratio and not just raw pixel dimensions?