I use WordPress native gallery – and it's output for each image is that:
<dl class="gallery-item">
<dt class="gallery-icon">
<a href="(...)"><img src="(...)"></a>
</dt>
<dd class="wp-caption-text gallery-caption">
Caption here
</dd>
</dl>
The source that does that is:
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);
$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" />';
}
I want that the output be:
<dl class="gallery-item">
<dt class="gallery-icon">
<a href="(...)">
<img src="(...)">
Caption here
</a>
</dt>
</dl>
But I can't get the link -or- the image, since the link is printed with the image from "$link". How can I do that?