lightbox gallery, caption as anchor showing same image twice in lightbox.

Im using the lightbox gallery wordpress plugin on a site. I need the caption to have the same link as the image. So if the image or caption is clicked the same image is shown. I have hacked the plugin so the caption is a link but it shows the same image twice. Hope this code makes sense.

<a href="'.$lightbox_link[0].'" title="'.esc_attr($attachment->post_excerpt).'"';
        if ( $nofollow == "true" ) $output .= ' rel="nofollow"';
        if ( $options['global_settings']['lightbox_gallery_loading_type'] == 'highslide' ) :
            $output .= ' class="highslide" onclick="return hs.expand(this,{captionId:'."'caption".$attachment->ID."'".'})"';
        elseif ( $options['global_settings']['lightbox_gallery_loading_type'] == 'colorbox' ) :
            $output .= ' rel="'.$class.'"';
        endif;
        $output .= '><img src="'.$thumbnail_link[0].'" width="'.$thumbnail_link[1].'" height="'.$thumbnail_link[2].'" alt="'.esc_attr($attachment->post_excerpt).'" /></a>

‘;
This outputs the image from the wordpress gallery in my wiziwig.

Read More

Now the following outputs the caption if there is one. Notice I have added the

 <a href="'.$thumbnail_link[0].'">

after the fist $output. as well as the closing a This is what causing the error.

if ( $captiontag && (trim($attachment->post_excerpt) || trim($attachment->post_content) || isset($metadata)) ) {
            $output .= '<a href="'.$thumbnail_link[0].'"><'.$captiontag.' class="gallery-caption" id="caption'.$attachment->ID.'">';
            if($attachment->post_excerpt) $output .= '<span class="imagecaption">'.$attachment->post_excerpt . "</span><br />n";
            if($attachment->post_content) $output .= '<span class="imagedescription">'.$attachment->post_content . "</span><br />n";
            if($metadata) $output .= '<span class="imagemeta">'.$metadata.'</span>';
            $output .= '</'.$captiontag.'></a>';
        }

Thank you

Related posts

Leave a Reply