<?php
/**
 * @package     Joomla.Site
 * @subpackage  Layout
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('JPATH_BASE') or die;
use Joomla\Registry\Registry;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Layout\LayoutHelper;
$params  = $displayData->params;
$images  = json_decode($displayData->images);

// Get contentype
$attribs = new Registry ($displayData->attribs);
$content_type = $attribs->get('ctm_content_type', 'article');
?>
<?php if ($content_type=='video') :?>
<!-- Video -->
	<div id="ja-main-player" class="embed-responsive embed-responsive-16by9">
		<span itemscope itemtype="http://schema.org/VideoObject" style="display:none;">
			<span itemprop="name"><?php echo $displayData->title; ?></span>
			<span itemprop="description"><?php echo $displayData->text; ?></span>
			<img itemprop="thumbnailUrl" src="<?php echo Uri::base() ?><?php echo $params->get('ctm_thumbnail'); ?>" alt="<?php echo $displayData->title; ?>"/>
			<meta itemprop="uploadDate" content="<?php echo HTMLHelper::_('date', $displayData->publish_up, 'c'); ?>"/>
		</span>
		<div id="videoplayer">
		  <?php echo LayoutHelper::render('joomla.content.video_play', array('item' => $displayData, 'context' => 'featured')); ?>
		</div>
	</div>
<!-- // Video -->
<?php else :?>
	<?php if (isset($images->image_fulltext) && !empty($images->image_fulltext)) : ?>
		<?php $imgfloat = empty($images->float_fulltext) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
		<figure class="pull-<?php echo htmlspecialchars($imgfloat, ENT_COMPAT, 'UTF-8'); ?> item-image">
			<img src="<?php echo htmlspecialchars($images->image_fulltext, ENT_COMPAT, 'UTF-8'); ?>"
				 alt="<?php echo htmlspecialchars($images->image_fulltext_alt, ENT_COMPAT, 'UTF-8'); ?>"
				 itemprop="image"/>
			<?php if ($images->image_fulltext_caption !== '') : ?>
				<figcaption class="caption"><?php echo htmlspecialchars($images->image_fulltext_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
			<?php endif; ?>
		</figure>
	<?php endif; ?>
<?php endif ;?>