<?php
/**
 * Output of the single match screenshots.
 *
 * @package cyberpress/templates
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound

$match             = cyberpress()->get_the_match();
$match_screenshots = $match->get_screenshots();

if ( $match_screenshots && ! empty( $match_screenshots ) ) : ?>
    <h3><?php echo esc_html__( 'Screenshots', 'cyberpress' ); ?></h3>

    <div class="cyberpress-screenshots">
        <?php
        foreach ( $match_screenshots as $screenshot_id ) {
            $url = wp_get_attachment_image_src( $screenshot_id, 'full' );
            ?>
            <a href="<?php echo esc_url( $url[0] ); ?>" class="cyberpress-screenshot" data-size="<?php echo esc_attr( $url[1] . 'x' . $url[2] ); ?>">
                <?php echo wp_get_attachment_image( $screenshot_id, 'large' ); ?>
                <div class="cyberpress-screenshot-overlay">
                    <?php CyberPress_Template_Parts::get_template( 'icons/search.php' ); ?>
                </div>
            </a>
            <?php
        }
        ?>
    </div>
<?php endif; ?>
