次のコードを操作して、新しいタブでリンクを開こうとしています。fancybox 1.3.4ポップアップに埋め込まれています。問題は target="_blank" の追加であり、onclick 関数が無視され、リンクが親ページで開かれます。また、javascript void (0) target"_blank" を使用してみましたが、ページを新しいタブに残すことができましたが、新しいページが表示されたときに空白です。
これは、fancybox を離れて新しいタブで開くために操作しようとしているコードの行です。
$link = ($attachment_meta)? "<a href='$attachment_meta'>$image</a>" : $image;
ex: $link = ($attachment_meta)? "<a href='$attachment_meta'
target'_blank'>$image</a>" : $image; <-- adding target_blank in code
does not work!--
これはコードのスニペットです:
if( 'custom' == $attr['link']){
$image = wp_get_attachment_image($id, $size, false);
$attachment_meta = get_post_meta($id, '_rt-image-link', true);
$link = ($attachment_meta)? "<a href='$attachment_meta'>$image</a>" : $image;
} else {
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
}
$output .= "<{$itemtag} class='gallery-item'>";
$output .= "
<{$icontag} class='gallery-icon'>
$link
</{$icontag}>";
if ( $captiontag && trim($attachment->post_excerpt) ) {
$output .= "
<{$captiontag} class='wp-caption-text gallery-caption'>
" . wptexturize($attachment->post_excerpt) . "
</{$captiontag}>";
}
$output .= "</{$itemtag}>";
if ( $columns > 0 && ++$i % $columns == 0 )
$output .= '<br style="clear: both" />';
}