Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #4127

    Hello there,

    I’m trying to display 6 random post images as a sidebar widget in the Newscast theme (2.0.2, WP 3.1.1) and open them in Lightbox to view these images when the user clicks on any of them (same behavior as in single post view). I am pretty sure someone already asked about Image Galleries in the sidebar and was directed to a Gallery plugin instead, but I couldn’t find the thread.

    So far, I’m able to display the images just fine, but I don’t know how to force Lightbox to trap them and display them:

    <div class="image-gallery">
    <?php
    $image_query = new WP_Query('posts_per_page=6&orderby=rand&cat=-23,-25');
    $imageArray = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_name' );
    $imageURL = $imageArray[0];
    while ($image_query->have_posts()) : $image_query->the_post(); ?>
    <div class="imagebox"><a title="<?php the_title(); ?>" href="<?php echo $imageURL; ?>" rel="bookmark"><?php the_post_thumbnail(array(61,61), array ('class' => 'rounded3')); ?></a></div>
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
    </div>

    I also tried to integrate the preview_image variable contained in single.php file into the above code but I was unsuccessful.

    It would be desirable if all 6 pictures could be browsed from Lightbox as well. Thanks for your help.

    #45091

    Hey,

    Can you post a link to a page with this code on?

    I’m sure it’s relatively straight forward to make the images appear in a lightbox but want to see 1st hand how it displays to better help you.

    James

    #45092

    Hi James,

    Thanks for your reply. Right now, the site is down (talking about bad luck), but I’ll let you know as soon as it is up so you can take a look.

    Pom

    #45093

    Hello again,

    The site is back up again. Here’s the (Email address hidden if logged out) /” rel=”nofollow”>link. Please note that the site is password-protected, so the login info is included in the url.

    Thanks for taking a look at this.

    Pom

    #45094

    Hey,

    try:

    <div class="image-gallery">
    <?php
    $image_query = new WP_Query('posts_per_page=6&orderby=rand&cat=-23,-25');
    $imageArray = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_name' );
    $imageURL = $imageArray[0];
    while ($image_query->have_posts()) : $image_query->the_post(); ?>
    <div class="imagebox"><a title="<?php the_title(); ?>" href="<?php echo $imageURL; ?>" rel="lightbox"><?php the_post_thumbnail(array(61,61), array ('class' => 'rounded3')); ?></a></div>
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
    </div>

    #45095

    Hi Dude,

    That did it! Although I must say I I can’t believe it was that simple, hahaha.

    On another note, what would image resolution do you recommend for pictures in Lightbox in general?

    I’ve been noticing that pictures take a while to display right now and but I’m 100% sure it has to do with image resolution.

    Thanks again to the both of you.

    #45096

    Maybe try to reduce the image quality (if they’re jpgs). Tools like http://www.obviousidea.com/windows-software/light-image-resizer/ help you to batch resize or adjust the quality. I’d suggest up to 1000px width – everything else can cause problems (I’d even recommend 800px only…)

    #45097

    Hey, Dude.

    I think between the image resizer and Smushit I’ll be able to make the images load faster.

    Thank you and James for all your help again.

    Pom

    #45098

    Glad that we could help you :)

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

The topic ‘How to get Lightbox to display Images in Sidebar Gallery’ is closed to new replies.