<?php
/**
 * Item thumbnail
 *
 * This template can be overridden by copying it to yourtheme/smart-post-show-pro/templates/item/thumbnail.php
 *
 * @package    Smart_Post_Show_Pro
 * @subpackage Smart_Post_Show_Pro/public
 */

$lazy_load = isset( $_post_thumb_setting['pcp_img_lazy_load'] ) ? $_post_thumb_setting['pcp_img_lazy_load'] : true;
$lazy_load = apply_filters( 'pcp_img_lazy_load', $lazy_load );
if ( ( 'carousel_layout' !== $layout && 'slider_layout' !== $layout && 'thumbnails_slider' !== $layout ) && $lazy_load && ! is_admin() ) {
	wp_enqueue_script( 'pcp_lazy' );
	$image = sprintf( '<img data-sps_src="%1$s" %5$s class="pcp-lazyload" width="%2$s"  height="%3$s" alt="%4$s">', $thumb_url, $pcp_image_attr['width'], $pcp_image_attr['height'], $alter_text, $retina_img_attr );
} else {
	$image = sprintf( '<img %5$s src="%1$s" width="%2$s" height="%3$s" alt="%4$s">', $thumb_url, $pcp_image_attr['width'], $pcp_image_attr['height'], $alter_text, $retina_img_attr );
}
?>
<div class="pcp-post-thumb-wrapper">
	<div class="sp-pcp-post-thumb-area">
		<?php
		if ( 'product' === $pcp_select_post_type && 'product' === get_post_type( $slide ) ) {
			$product = wc_get_product( $slide->ID );
			if ( $product->is_on_sale() ) {
				?>
				<div class="sp-pcp-sale-text" title="On Sale"><?php echo apply_filters( 'sp_pcp_woocommerce_sale_text', __( 'Sale!', 'smart-post-show-pro' ), $scode_id ); ?></div>
				<?php
			}
		}
		?>
		<?php if ( 'popup' === $pcp_page_link_type ) { ?>
		<a class="sp-pcp-thumb popup-modal" aria-label="<?php echo esc_attr( $pcp_image_attr['aria_label'] ); ?>" href="" <?php echo esc_attr( $pcp_link_rel_text ); ?>>
		<?php } elseif ( 'none' === $pcp_page_link_type ) { ?>
			<div class="sp-pcp-thumb" aria-label="<?php echo esc_attr( $pcp_image_attr['aria_label'] ); ?>" <?php echo esc_attr( $pcp_link_rel_text ); ?>>
		<?php } else { ?>
			<a class="sp-pcp-thumb" aria-label="<?php echo esc_attr( $pcp_image_attr['aria_label'] ); ?>" href="<?php the_permalink( $slide ); ?>" target="<?php echo esc_attr( $pcp_link_target ); ?>" <?php echo esc_attr( $pcp_link_rel_text ); ?>>
			<?php
		}
		if ( empty( $pcp_image_attr['video'] ) && empty( $pcp_image_attr['audio'] ) ) {
			echo apply_filters( 'sp_pcp_featured_image', $image, $slide->ID );
		} elseif ( $pcp_image_attr['video'] ) {
			?>
			<div class='sp-pcp-post-video-thumb-area'><?php echo $pcp_image_attr['video']; ?></div>
			<?php
		} elseif ( $pcp_image_attr['audio'] ) {
			?>
		<div class='sp-pcp-post-audio-thumb-area'><?php echo $pcp_image_attr['audio']; ?></div>
		<?php } ?>

		<?php
		if ( 'none' === $pcp_page_link_type ) {
			echo '</div>';
		} else {
			echo '</a>';
		}
		?>
		
		<?php
		// Taxonomy terms over thumbnail.
		self::over_thumb_meta_taxonomy( $post_meta_fields, $show_post_meta, $slide );
		?>
	</div>
</div>
