<?php
/**
 * Displays the featured image.
 */

if ( has_post_thumbnail() && ! post_password_required() ) {

	$featured_media_animation_delay_class = '';

	// Animate featured image only on archive pages.
	if ( ! is_singular() ) {
		global $eisai_delay;

		$featured_media_animation_delay_class = ' animation-delay-' . $eisai_delay;
	}
	?>
	<figure class="featured-media">

		<div class="featured-media-inner<?php echo esc_attr( $featured_media_animation_delay_class ); ?>" data-uk-scrollspy="cls: uk-animation-slide-bottom-small" style="visibility: hidden;">

			<?php
			if ( ! is_singular() ) {
				echo sprintf( '<a class="uk-link-reset" href="%s" rel="bookmark">%s</a>', esc_url( get_permalink() ), get_the_post_thumbnail( get_the_id(), 'large' ) );
			} else {
				the_post_thumbnail();
			}

			$caption = get_the_post_thumbnail_caption();

			if ( $caption ) {
				?>

				<figcaption class="wp-caption-text"><?php echo esc_html( $caption ); ?></figcaption>

				<?php
			}
			?>

		</div> <!-- .featured-media-inner -->

	</figure> <!-- .featured-media -->
	<?php
}
