I’ll never be able to wrap my old head around this syntax but it works. THANKS!
I fine-tuned it into this with plenty of trial and error, I hope this gets your approval. π
add_filter( 'prepend_attachment', function( $attachment_content ) {
global $post;
// get the attachment caption
$excerpt = '<figcaption class="wp-caption-text">' . $post->post_excerpt . '</figcaption></figure>';
// set the attachment image size to 'large'
$attachment_content = sprintf( '<figure class="wp-caption">%s', wp_get_attachment_link(0, 'large', false) );
// return the attachment content
return $attachment_content . $excerpt;
} );
Final result: https://www.alex-kunz.com/portfolio/tabletop-tide-pools/filaments-of-green/#main
Thanks again, your help is very much appreciated.
Alexander.