Is it possible to print two different url's from the same featured image/thumbnail?

So i have set up my image size..

add_image_size( 'full-size', 460, 9999 ); 
add_image_size('fixed-height', NULL, 75, false);

I need to pull the url of these two images sizes into the post like so..

<li><img src="full-size.jpg" ref="fixed-height.jpg" ></li>

Obviously i could not use the normal way..

<li><img src="<?php the_post_thumbnail('full-size'); ?>" ref="<?php the_post_thumbnail('fixed-height'); ?>" ></li>

Is it possible to do what i'm after, or no go?

Thanks for anyone that can help :)

2 Answers 2


no problem to have 2 or more post thumbnails of different sizes. but what is the "ref" attribute ? do you mean "rel" ?

anyhow - example from the :codex

 if ( has_post_thumbnail()) {
   $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
   echo '<a href="' . $large_image_url[0] . '" title="' . the_title_attribute('echo=0') . '" >';
   echo '</a>';

mind that the_post_thumbnail() will give you the full HTML for the image , to get other attributes, you will need to use get_the_post_thumbnail() or get_post_thumbnail_id() with wp_get_attachment_image_src

    $fullsize = wp_get_attachment_image_src( get_post_thumbnail_id(), 'fullsize' );
    $fixed_height = wp_get_attachment_image_src( get_post_thumbnail_id(), 'fixed_height' ) ;
// returns array in which :
echo $fullsize[0] ;// url of fullsize 
echo $fixed_height[0] ;// url of fixed_height
  • Its for the image gallery pikachoose.com it requires ref. Thanks i've found a way using get_the_post_thumbnail
    – Jezthomp
    Feb 27, 2012 at 16:01

I would combine the_post_thumbnail() with get_intermediate_image_sizes(), e.g.:

// globalize $post object
global $post;

// Get the array of registered image sizes
$image_sizes = get_intermediate_image_sizes();

// Loop through the image sizes, and 
// use them to output the Featured Image
foreach ( $image_sizes as $image_size ) {
    echo '<li>';
    the_post_thumbnail( $post->ID, $image_size );
    echo '</li>';


Note: I don't think get_intermediate_image_sizes() sorts the array of image sizes, so you may need to manipulate the return value, if you want to output the images ordered by size.

Your Answer

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

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