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'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>    
share|improve this question
    
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
add comment

1 Answer 1

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>
</a>

Reference links: get_post_thumbnail_id, wp_get_attachment_image_src

share|improve this answer
    
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
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.