wordpress disable image being viewed in gallery -


i included code image attachment template (image.php) file display gallery of thumbnails 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 $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 detect image being viewed , disable / highlight image in gallery thumbnail?

you go it. have current image using get_attachment_link() , compare get_attachment_link($imageid)

here 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 $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 same in list, remove href                          {                                $thumblist .= '<li class="span1">'.$the_b_img.'</li>';                           }                       }                     $thumblist .= '</ul>';                 }                  return $thumblist;             } } 

documentation on get_attachment_link() available here


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -