5

I have added an image size with

add_image_size('gallery-thumb', 48, 48);

Why when I do

array_slice(wp_get_attachment_image_src($firstimg->ID, 'gallery-thumb'))

I get the link to the full sized image?

UPDATE

Somehow it appears that even when I do

wp_get_attachment_image_src($photo->ID, array(48,48))

I get the thumbnail image (150, 150)

2 Answers 2

7

Does the 48x48 thumbnail file exist? If not, you can use a plugin like Regenerate Thumbnails.

4

I've been wrestling with the same issue this afternoon. The way wordpress handles thumbnails isn't very intuitive, but it seems that:

  • Thumbnails are only generated on upload. So if you're developing & have added a new size, you'll need to delete and replace your media or regenerate the thumbnails with a plugin (I haven't looked for a native solution - seems ridiculous that there isn't one!) like Scribu suggests in order to use it.

  • The size parameter seems like it will generate thumbnails of an arbitrary size, but I believe it is actually just mapping to the closest thumbnail size that has already been generated. That's why you're getting 150x150 pixel thumbs back when you request 48x48 pixel thumbs.

This article goes into much more detail: http://www.studiograsshopper.ch/web-development/wordpress-featured-images-add_image_size-resizing-and-cropping-demo/

Your Answer

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

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