<?php
/**
 * Card Image - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $image_url        Image url.
 *   @type string $size             Image size. One of: 'small', 'tiny'.
 *   @type string $style            Image style. One of: 'bordered'.
 *   @type string $margin           Image margin. One of: 'bottom'.
 * }
 */

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

$modifiers = [ 'size', 'style', 'margin' ];

$defaults = [];

foreach ( $modifiers as $modifier ) {
  $defaults[$modifier] = '';
}

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

$wrapper_classes = [
  'orokublocks-card__image-container'
];

foreach ( $modifiers as $modifier ) {
  if ( $options[$modifier] !== '' ) {
    $wrapper_classes[] = 'orokublocks-card__image-container--' . $modifier . '--' . $options[$modifier];
  }
}

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