Featured image with the same height thumbs returns wrong thumb

I think you’ve hit interesting logic issue in image_get_intermediate_size(). This function loops through available images and tries to find best possible match for custom dimensions you provided.

First it attempts to find image as per comment in code:

// already cropped to width or height; so use this size

See the issue? Not image, perfectly matching dimensions, but image that matches in width or height, with remaining dimension being smaller or equal than required to fit in dimensions.

So your 300×200 image has equal height and fits inside 540×200 dimension you want (and probably comes earlier in meta data) so WP happily grabs it to use.

Interestingly, the class is displayed with the correct…

No mystery there, class is simply generated from your input, without regard if values make sense and/or available.

Leave a Comment