https://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src#Parameters leads me to believe wp_get_attachment_image_src( $thumb_id, array(100, 100) )[0] would return a 100x100 thumbnail, but it always just returns the full-sized image.

Any help would be greatly appreciated.

3 Answers 3


I think this code will help you:

$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false, '' );
echo '<img src="'.$src[0].'">';
  • What error is showing Commented Apr 9, 2016 at 12:50
  • echo '<img src="'.$src[0].'">'; Sorry try this Commented Apr 9, 2016 at 12:51

you need to have predefined image sizes, WP have 3 default sizes as 100x100 thumbnail, 300x300 medium and 800x800 large, and I have an aditional size called img-polaroid 700x320 defined on functions.ini.

So the code to get images is: $image_id=get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id,'img-polaroid'); $image_url=$image_url[0];

'img-polaroid' is the '$size' retreived 700x320, and the way to print the image is: img src="php echo $image_url" class="img-polaroid" style="margin:5px 0px 15px;"

Where class="img-polaroid" is the real size to print like 100x100 or 200x100 with style of polaroid photo defined on CSS styles; or you can use inside img html code heigh=100 wight=100. with both methods the image will be clear and good definition. for my purposes img-polaroid has a size 320x200 and defined also as responsive size.

If you get the image $image_url = wp_get_attachment_image_src($image_id,'thumbnail'); and tries to print on higher size the image will be blurred. ***

So try to get the image size closest to the size you need to print to not overload your page

  • Even when I try to fetch an image by its name, it still results in the full sized image. For instance, echo wp_get_attachment_image_src( $thumb, 'medium' )[0]; still results in a full sized image. Commented Jul 1, 2015 at 15:14
  • @corysimmons img src=(phpcode &image_url) will print the image, medium, full, large is only the resolution size, try to adjust with height and width inside CSS style or html codes. if still appears as full size, you need to override the img style with another one using a comment !important, ex .thumb img{widht:100px !important; height:auto} Commented Jul 1, 2015 at 15:41

... leads me to believe wp_get_attachment_image_src( $thumb_id, array(100, 100) )[0] would return a 100x100 thumbnail...

That isn't quite what happens. Most of the work is done by image_downsize() as you can see from near the top of the wp_get_attachment_image_src() :

692         // get a thumbnail or intermediate image if there is one
693         if ( $image = image_downsize($attachment_id, $size) )
694                 return $image;

If you look at the notes for that function you will see:

134  * The URL might be the original image, or it might be a resized version. This
135  * function won't create a new resized copy, it will just return an already
136  * resized one if it exists.

What you get (near as I can tell) is the nearest size to the one requested with an array containing the requested image dimensions or the actual image dimensions if the requested size is larger than the largest image. You are expected to do the rest with HTML and CSS.

  • So how do you get a resized image? Commented Oct 13, 2016 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.