<?php
/**
 * The template to display entry image.
 *
 * This template can be overridden by copying it to
 * your-child-theme/views/entry/image.php.
 *
 * @param array $args
 *
 * @package MadeByAura\Prime
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime;

use MadeByAura\Prime\Helpers\Markup;

defined( 'ABSPATH' ) || die();

// Do not proceed if there is no post thumbnail.
if ( ! has_post_thumbnail() ) {
	return;
}

// Merge incoming `$args` with defaults.
$args = array_replace_recursive(
	[
		'image_size' => 'aura_thumbnail',
		'link'       => true,
		'class'      => '',
	],
	$args,
);

// Set variables.
$image_size = apply_filters( 'aura_theme_entry_image_size', $args['image_size'] );

// Set CSS classes.
$classes[] = $args['class'];
$classes[] = 'aura-entry-image';
?>

<figure class="<?php Markup::echo_classes( $classes ); ?>">
	<?php if ( $args['link'] ) : ?>
		<a href="<?php the_permalink(); ?>">
	<?php endif; ?>

	<?php the_post_thumbnail( $image_size ); ?>

	<?php if ( $args['link'] ) : ?>
		</a>
	<?php endif; ?>
</figure>
