<?php
/**
 * Image Tag - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $image_url                  Tag image URL.
 *   @type string $size                       Tag size. One of: 'tiny', 'small', 'medium', 'big'.
 *   @type string $style                      Tag style. One of: 'pill', 'round'. Default: 'round'.
 *   @type string $image_style                Tag image styles. One of: 'no--border'.
 * }
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
  exit;
}

$defaults = [
  'image_url'   => '',
  'size'        => '',
  'style'       => 'round',
  'image_style' => ''
];

$options = array_merge( $defaults, $args );

$wrapper_classes = [
  'orokublocks-image-tag'
];

if ( array_key_exists( 'size', $options ) ) {
  $wrapper_classes[] = 'orokublocks-image-tag--size--' . $options['size'];
}

if ( array_key_exists( 'style', $options ) ) {
  $wrapper_classes[] = 'orokublocks-image-tag--style--' . $options['style'];
}

$image_wrapper_classes = [
  'orokublocks-image-tag__image-container'
];

if ( array_key_exists( 'image_style', $options ) ) {
  $image_wrapper_classes[] = 'orokublocks-image-tag__image-container--style--' . $options['image_style'];
}

?>
<?php if ( $options['image_url'] !== '' ) : ?>
<div class="<?php echo esc_attr( implode( ' ', $wrapper_classes ) ); ?>">
  <div class="<?php echo esc_attr( implode( ' ', $image_wrapper_classes ) ); ?>">
    <img class="orokublocks-image-tag__image" src="<?php echo esc_url( $options['image_url'] ); ?>" alt="">
  </div>
</div>
<?php endif; ?>