Display thumbnail only if requested size exists

Assuming the question is about wp_get_attachment_image_src.
It could be also about wp_get_attachment_link, but, although related, this analysis doesn’t includes it.


Got aware of this issue answering this question: How can I view all WP generated thumbnails in Media Manager?.
Refer to it to see a working code regarding the issue on this Question.

And it lead to this WordPress forum topic.


The function wp_get_attachment_image_src( $attachment_id, $size, $icon ) returns an array containing:

[0] => url  
[1] => width  
[2] => height  
[3] => is intermediate

If [3] is false, the original image data is returned.


Both wp_get_attachment_image_src and wp_get_attachment_link rely in the function image_downsize, inside /wp-includes/media.php.
And that’s where this 4 items array is being returned.

Leave a Comment