Site logo

Archived topic

Scale down just a special thumbnail-size in Wordpress

5 replies · Started by Kathrin on February 3, 2022

Viewing posts 1–6 of 6

Maybe you can help me in that case:

I just have very few images in the portrait-format that are used in my blog posts. They have the following size 426x639 px. When I regenerate all existing thumbnails, I don't want that for the portrait-format a thumbnail with the size 300x200 px is created, because that is useless. Is there a possibility to exclude the portrait-format from that thumbnail-size and use for it an own size for example 300x450 px. So an image with the size 426x639 px should only scaled down to a thumbnail size of 300x450 px. Is there a way?

Greetings Kathrin

hi Kathrin,

I'm not sure I fully understand what you mean.

I've checked the post-thumbnails of your site and they seem to be using full or large size images.

By portrait format, do you mean you have a registered image size portrait-format?

If it's about scaling down or scaling up a displayed image then that should be possible w/ CSS.

But it seems like what you meant is for WordPress to conditionally exclude using of a specific registered image size on a specific image's SRCSET. That requires a filter to change how your post-thumbnail displays.

Perhaps I'm completely missing what you mean. Can you explain further? Let us know.

Hi Elvin, how should I explain that...

I have used for some images the format 426x639 (on edge), but these are perhaps only 10 images in about 400 blog posts. Now I have to generate a new image size for mobiles, so that on smaller devices a smaller image format is used (696x464px --> 300x200px). But this format doesn't fit for on edge images (426x639 px). So when I upload a new image or regenerate the existing thumbnails, I just want that images with the format 426x639 px are scaled down to a 300x450 thumbnail and not to a 300x200px thumbnail. They should be excluded from 300x200 :) Is there a way to do that?

Greetings Kathrin

Hi there,

No the add_image_size function cannot be used selectively on specific images.

https://developer.wordpress.org/reference/functions/add_image_size/

If it is possible it would require custom development which is out of our scope.

But to note WP will identify a portrait image.
A thumbnail size that is set to W X H will have its values flipped to H x W.
So your 300x200 landscape size, will become 200x300 on a portrait image. Not the 200 will be variable based on the original images aspect ratio.

Dear David,

thank you very much for your answer.

Greetings Kathrin

You're welcome

This archived topic is closed to new replies.