https://codex.tacoemojishirt.com.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 certainly return a 100x100 thumbnail, however it constantly just returns the full-sized image.

You are watching: Wp_get_attachment_image_src

Any help would be considerably appreciated.


*

I think this password will aid you:

$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgfull"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg, false, "https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg );echo "https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg

*
."https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg>"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg;


*

... Leads me to think wp_get_attachment_image_src( $thumb_id, array(100, 100) )<0> would return a 100x100 thumbnail...

That isn"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgt rather what happens. Many of the occupational is excellent by image_downsize() together you deserve to see from close to the optimal of the wp_get_attachment_image_src() :

692 // acquire a thumbnail or intermediate picture if there is one693 if ( $image = image_downsize($attachment_id, $size) )694 return $image;If you look in ~ the notes because that that function you will see:

134 * The URL can be the original image, or it can be a resized version. This135 * function won"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgt develop a brand-new resized copy, it will just return one already136 * resized one if that exists.What you gain (near as I can tell) is the nearest dimension to the one requested with an array containing the requested photo dimensions or the actual photo dimensions if the asked for size is larger than the biggest image. You room expected to execute the remainder with HTML and also CSS.


re-publishing
boost this answer
follow
answer Jul 1 "https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg15 at 2:31
*

s_ha_dums_ha_dum
62.8k1212 gold badges7373 silver- badges164164 bronze badges
1
include a comment |
1
you require to have predefined picture sizes, WP have actually 3 default sizes as 100x100 thumbnail, 300x300 medium and 800x800 large, and also I have an aditional size dubbed img-polaroid 700x320 identified on functions.ini.

See more: Do Androids Dream Of Electric Sheep Chapter Summary & Analysis

So the password to acquire images is:$image_id=get_post_thumbnail_id();$image_url = wp_get_attachment_image_src($image_id,"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgimg-polaroid"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg);$image_url=$image_url<0>;

"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgimg-polaroid"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg is the "https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg$size"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg retreived 700x320, and also the method to publish the photo is:img src="https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgphp echo $image_url"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg class="https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgimg-polaroid"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg style="https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgmargin:5px 0px 15px;"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg

Where class="https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgimg-polaroid"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg is the real size come print choose 100x100 or 200x100 with format of polaroid photo defined on CSS styles; or you have the right to use inside img html code heigh=100 wight=100. Through both methods the image will be clean and good definition. Because that my purposes img-polaroid has a size 320x200 and also defined likewise as responsive size.

If you get the picture $image_url = wp_get_attachment_image_src($image_id,"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpgthumbnail"https://tacoemojishirt.com/wp-get-attachment-image-src/imager_2_7878_700.jpg); and tries to print on higher size the photo will it is in blurred. ***

So try to acquire the photo size closest come the dimension you have to print to no overload your page