<?php
/**
 * AUX Media Slab template
 */

use WP_AUX\Entities\AuxFramework\Partials\CaptionedMediaEntity;

$mediaFile = aux_get_field('media_slab_file');
if ('video' === aux_get_field('media_slab_media_source')) {
  switch (aux_get_field('media_slab_video_switch')) {
    case 'internal':
      $mediaFile = aux_get_field('media_slab_video_file');
      break;
    case 'external':
      $mediaFile = aux_get_field('media_slab_video_link');
      break;
  }
}

// Create captioned media partial, setting the file, heading, and credit from user input
$captionedMedia = CaptionedMediaEntity::create(
  $mediaFile,
  aux_get_field('media_slab_media_source'),
  aux_get_field('media_slab_caption'),
  aux_get_field('media_slab_credit')
)
  ->setIsSlab(true)
  ->setStyle(aux_get_field('media_slab_style'))
  ->setIsDarkMode('maroon' === aux_get_field('media_slab_caption_background'));

// Render captioned media partial
echo $captionedMedia;
