Show Multiple Size URL of one Featured Image/Thumbnail?

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

So i have set up my image size..

Read More
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 🙂

Related posts

Leave a Reply

2 comments

  1. 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

     <?php 
     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') . '" >';
       the_post_thumbnail('thumbnail');
       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
    
  2. I would combine the_post_thumbnail() with get_intermediate_image_sizes(), e.g.:

    <?php
    // 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.