<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Safe variables with absolute string/integer boundary validation
 */
$gridpress_card_counter = sanitize_html_class( $gridpress_card_counter ?? '' );

// Extract variables with null fallbacks outside the layout markup
$gridpress_card_url = $gridpress_card_data['url'] ?? '';
$gridpress_card_img = $gridpress_card_data['imag_url'] ?? '';

// Sanitize ternary condition logic for classes cleanly
$gridpress_size_class = ( int ) $gridpress_card_counter < 3 ? ' small' : '';
?>

<div class="jc-cards<?php echo esc_attr( $gridpress_size_class ); ?>">
    <div class="jc-cards-image">
        <a class="jc-cards-image-wrap" href="<?php echo esc_url( $gridpress_card_url ); ?>">
            <img
                src="<?php echo esc_url( $gridpress_card_img ); ?>"
                alt="<?php echo esc_attr__( 'Image', 'gridpress-grid-layout-design' ); ?>"
            >
        </a>
    </div>
</div>