1

サイトでライトボックス ギャラリーのワードプレス プラグインを使用しています。キャプションに画像と同じリンクが必要です。したがって、画像またはキャプションをクリックすると、同じ画像が表示されます。プラグインをハッキングしたので、キャプションはリンクになっていますが、同じ画像が 2 回表示されます。このコードが理にかなっていることを願っています。

<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>

'; これにより、wiziwig の wordpress ギャラリーから画像が出力されます。

以下は、キャプションがある場合はキャプションを出力します。追加したことに注意してください

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

最初の $output の後。これがエラーの原因です。

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>';
        }

ありがとうございました

4

0 に答える 0