I'm using the code below to get the posts featured image URL. I need to be able to get the large size image, right now it's getting the URL to the original size image.

<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID, 'ttrust_post_thumb_big'), array( 5600,1000 ), false, '' );?>

<a href="<?php the_permalink() ?>" rel="bookmark" class="imagewrap"><div style="background: url(<?php echo $src[0]; ?> ) !important;"></div></a>    
  • replace ttrust_post_thumb_big with large and see? – its_me Jul 19 '12 at 2:31
  • No it still gets the full size image – Anagio Jul 19 '12 at 2:56
  • When are you setting the background? It might be already set by the time you try to change it. – fdsa Jul 19 '12 at 3:15

There are some mistakes in the code you are using (AFAIK):

  1. get_post_thumbnail_id($post->ID, 'ttrust_post_thumb_big') only has one parameter, that is post_id. So, it should just be get_post_thumbnail_id($post->ID)

  2. '' — there's no 4th parameter for wp_get_attachment_image_src

  3. array( 5600,1000 ) defines the $size of the image you want to be shown. You should be using 'large' (string) since that's what you said you need.

Okay, now try this:

<a href="<?php the_permalink() ?>" rel="bookmark" class="imagewrap">
    <div style="background: url(<?php wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); ?>) !important;"></div>

Reference links: get_post_thumbnail_id, wp_get_attachment_image_src

  • That just outputs background: url(Array) !important; – Anagio Jul 19 '12 at 3:56
  • @Anagio okay, try the edited code and let me know if it works. – its_me Jul 19 '12 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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