";
$output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div );
$i = 0;
foreach ( $attachments as $id => $attachment ) {
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
if ( isset($attr['link']) && 'file' == $attr['link'] ) {
// Then re-arrange the link to include the caption and rel="lightbox"
$pattern = "/title='(.*)'/"; // notice quote usage.
![]()
!
$slimbox_caption = esc_attr( $attachment->post_content );
$replace = 'rel="lightbox[gallery]" title="' . $slimbox_caption . '"';
$link = preg_replace($pattern, $replace, $link, 1);
// ^ replace only the first title="*" ^
}
$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 .= '
';
}
$output .= "
\n";
return $output;
}
?>