Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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)

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

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

share|improve this answer
add comment

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/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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