Lense theme – adding titles to images in the lightbox

In functions.php, change the gallery generators (which have the <img src=””> parts, to the following. I only changed the Masonry function, since that’s the only one I use.

In short: move $details outside the <a href> tag, and add a title to the <a href>

<div class="gallery-main row-items row-isotope <?php echo esc_attr( implode( ' ', $classes ) ); ?>">
    <?php while ( $gallery->have_posts() ) : $gallery->the_post(); ?>
        <div class="row-item">
            <div class="item">
                <?php $details = wp_prepare_attachment_for_js( get_the_ID() ); ?>
                <a title="<?php echo esc_attr( $details['title'] ); ?>" href="<?php echo esc_attr( wp_get_attachment_image_url( get_the_ID(), 'large' ) ); ?>" class="lense-lightbox">
                    <img src="<?php echo esc_attr( wp_get_attachment_image_url( get_the_ID(), 'lense_gallery_masonry' ) ); ?>" alt="<?php echo esc_attr( $details['caption'] ); ?>">
                </a>
            </div>
        </div>
    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>
</div>