ThemeShaper Forums » Thematic


WordPress Featured Image Thumbnails To The Full Size Image

(4 posts)
  • Started 10 years ago by universalsudhir
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. universalsudhir

    I am a WP/PHP fresher and and trying to link a wordpress featured thumbnail image to larger image url but having problem implementing the code in loop file. I want to use the code for a image gallery page.. with small thumbnails linking to a larger version of image.

    I have uploaded a set a featured image (thumbnail) which appears as thumbnail on the page but don't know where to upload and access the large image.

    With the code I am using I am able to get the link to short thumbnails but it only links to the same image urls (small thumbnails).

    Here's the code:
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <h1><?php the_title(); ?></h1><hr class="hr"/>
    <div id="portfolio_item_container">
    <div id="portfolio_items">
    $args = array( 'numberposts' => 9, 'offset'=> 0, 'category' => 4 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) : //setup_postdata($post); ?>
    <?php $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large'); ?>
    <div class="portfolio_item">
    <?php echo '';
    echo get_the_post_thumbnail($post->ID, 'medium');
    echo ''; ?>
    <?php endforeach; ?>

    Please help with the solution.

    Posted 10 years ago #
  2. Maybe I'm not be understanding what you're trying to do, but you don't have to write all that code to make a gallery.

    If that is all you're trying to do you can upload your images to a post or page, then insert "gallery" and choose link thumbnails to attachment or image file.

    I have a test of something similar here:

    If you are trying to do something more complicated, you'll have to wait for someone smarter to respond :)

    Posted 10 years ago #
  3. I just saw your other post, if you are having issues with the size of your photos displaying check your images.php file, that worked for me (thanks to HTViking)

    Posted 10 years ago #
  4. so you need to wrap your thumbnails in a link to a larger version of the image?

    $large = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
    echo '<a href="'. $large .'">'.get_the_post_thumbnail($post->ID, 'medium'); .'</a>';

    might work (didn't test it) or you could filter the post thumbnail html if you wanted to do it for every thumbnail across your site

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.