Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #376

    Hi Kriesi,

    Is it possible to include an image preview to posts appearing in an Archive list view?

    For example, when I click a category link I get an Archive list of posts in that category, but the list is text-only. Is it possible to add a small thumbnail or medium-sized image to this? Or is it possible to view an Archive list in grid view with medium images (as with the portfolio)?

    Thanks for your support!

    -meltedarts

    #31118

    You need to modify archive.php to accomplish this. Open it up and just after this code:

    while (have_posts()) : the_post();

    add this code:

    // check if we got a previe picture, and which one should be taken
    // (image resizing with "tim thumb" on? then we can take the big one and resize it)
    $preview_small = get_post_meta($post->ID, "_preview_small", true);
    $preview_medium = get_post_meta($post->ID, "_preview_medium", true);
    $preview_big = get_post_meta($post->ID, "_preview_big", true);

    //defaults:
    $preview = $preview_medium;
    $link_url = $preview_big;
    $lightbox = 'singlepost';
    $link = true;
    //change if necessary:

    // resizing? => take next sized picture
    if ($k_option['general']['tim'] == "1" && $preview_medium == "")
    {
    $preview = $preview_big;
    }

    // no bigpicture? => no lightbox
    if ($preview_big == "") { $lightbox = ''; $link = true; $link_url = get_permalink(); }
    // the kriesi_build_image function used here checks if the image should be resized.
    // the function is located in framework/helper_functions

    $preview = kriesi_build_image(array('url'=>$preview,
    'height'=> '250',
    'width'=> '250',
    'lightbox'=>$lightbox,
    'link'=>$link,
    'link_url'=>$link_url
    ));

    You then need to add this code:

    echo $preview; // echo the preview image

    immediately before this code:

    the_excerpt();

    To adjust the image size, change the value of height and width (both currently 250).

    #31119

    Thank you! This worked perfectly.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Add Images to Archive List?’ is closed to new replies.