wp_get_attachment_image_src returns the wrong image

by Edward   Last Updated April 28, 2018 11:08 AM

I uploaded an image my-image.jpg of dimension 1280x854, after that, I went to Dashboard > Media to crop it to 854x854. (Apply changes to All Image Sizes.)

This however only change its thumbnail in Media Library, when I click the thumbnail, the popup window shows still the original image, before cropped.

In the Uploads folder, I have checked that the cropped image files are existing, with name like my-image-e15249112352.jpg

I tried to get the image by its id:

wp_get_attachment_image_src(3629, 'large');

The expected return is

/path-to-image/my-image-e15249112352.jpg

but the actual return is

/path-to-image/my-image-1024x683.jpg


Answers 1


You are using 'large' size, and that is not the full image. For full image, you should use 'full' instead of 'large':

wp_get_attachment_image_src(3629, 'full');

Large image is size based on the settings in the WordPress Settings Media.

Milan Petrovic
Milan Petrovic
April 28, 2018 11:06 AM

Related Questions



Keep image EXIF info for resized image uploads?

Updated April 11, 2016 09:03 AM

How to crop image from image src

Updated June 12, 2017 17:08 PM