0

I'm trying to integrate a custom slider using a 3rdParty jQuery plugin onto the homepage.

I'm almost there. I need the original featured images and not the cropped ones.

<?php if (is_home()): ?>
<?php
$featured_posts = new WP_Query(array(
    'post_type' => 'post',
    'showposts' => 5,
    'tag' => 'featured'
));
?>
<div>
<?php while($featured_posts->have_posts()): $featured_posts->the_post(); ?>
    <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'featured-image'); ?>                        
    <a href='<?php the_permalink(); ?>'>
        <img src="<?php echo $image[0]; ?>" style="width:940px;height:500px" />
    </a>
<?php endwhile; ?>                    
</div>
<?php endif ?>                

The problem here is that all the images are of 516x340 dimension. How I get the original dimensioned image ?

1

The second parameter for wp_get_attachment_image_src is $size.

$size
(string/array) (optional) Size of the image shown for an image attachment: either a string keyword (thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, e.g. array(32,32). As of Version 2.5, this parameter does not affect the size of media icons, which are always shown at their original size.

http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

Per that Codex entry $size can take string values of "thumbnail, medium, large or full". You need "full" to get the full size image, which ought to be the original.

It seems to me like you could save yourself a little bit of trouble with wp_get_attachment_image instead of wp_get_attachment_image_src

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.