wordpress disable image being viewed in gallery

i included this code into my Image Attachment Template (image.php) file to display a gallery of thumbnails for the current post.

function show_all_gallery_thumbs() 
{
    global $post;
    $post = get_post($post);

     /* image code */
     $images =& get_children( 'post_type=attachment&post_mime_type=image&output=ARRAY_N&orderby=menu_order&order=ASC&post_parent='.$post->post_parent);

     if($images)
     {
         $thumblist = '<ul class="thumbnails">';

         foreach( $images as $imageID => $imagePost )
         {

             unset($the_b_img);
             $the_b_img = wp_get_attachment_image($imageID, array(64,64));
             $thumblist .= '<li class="span1"><a href="'.get_attachment_link($imageID).'" class="thumbnail">'.$the_b_img.'</a></li>';

          }

       $thumblist .= '</ul>';
    }

    return $thumblist;
}

how would i detect which image is being viewed and disable / highlight the image in my gallery thumbnail?

Related posts

Leave a Reply

1 comment

  1. you almost go it. all you have to do it get the current image using get_attachment_link() and compare it with your get_attachment_link($imageID)

    here is you code

        function show_all_gallery_thumbs() 
                {
                    global $post;
                    $post = get_post($post);
    
                     /* image code */
                     $images =& get_children( 'post_type=attachment&post_mime_type=image&output=ARRAY_N&orderby=menu_order&order=ASC&post_parent='.$post->post_parent);
    
                     if($images)
                     {
                         $img_current = get_attachment_link(); //get current viewed img
    
                         $thumblist = '<ul class="thumbnails">';
    
                         foreach( $images as $imageID => $imagePost )
                         {
    
                             unset($the_b_img);
                             $the_b_img = wp_get_attachment_image($imageID, array(64,64));
                             $img_list = get_attachment_link($imageID);
    
                             if ($img_current != $img_list)
                             {
                                   $thumblist .= '<li class="span1"><a href="'.$img_list.'" class="thumbnail">'.$the_b_img.'</a></li>';
                             }
                             else //If page img viewed is the same in list, remove href
                             {
                                   $thumblist .= '<li class="span1">'.$the_b_img.'</li>';
    
                             }
                          }
    
                       $thumblist .= '</ul>';
                    }
    
                    return $thumblist;
                }
    }
    

    documentation on get_attachment_link() is available here