<?php
$GLOBALS['TL_CSS'][] = \Contao\Config::get('uploadPath').'/cto_layout/css/customelements/ce_headerimage.css|static';
// responsive images
$objFile = \Contao\FilesModel::findByPk( $this->field('image')->value() );
if( $objFile !== null )
{
$objPicture = \Contao\Picture::create($objFile->path,deserialize( $this->field('image')->option('size') ) );
$arrMediaQueries = array();
if( $objPicture !== null )
{
$arrPicture = $objPicture->getTemplateData();
foreach($arrPicture['sources'] ?: array() as $data)
{
if( strlen($data['media']) < 1 )
{
continue;
}
$arrMediaQueries[] = '@media '.$data['media'].' { .ce_headerimage_'.$this->id.' { background-image:url('.$data['src'].') !important; } }';
}
}
if( count($arrMediaQueries) > 0 )
{
$GLOBALS['TL_HEAD'][] = '<style>'.implode("\n",$arrMediaQueries).'</style>';
}
}
?>
<div class="<?php echo $this->class; ?> ce_headerimage_<?php echo $this->id;?> block <?php echo $this->field('schema')->value(); ?> <?php echo $this->field('height_preset')->value(); ?> <?php echo $this->field('align')->value(); ?> <?php echo $this->field('valign')->value(); ?><?php if($this->field('invert')->value()): ?> color-white<?php endif; ?><?php if($this->field('img_align')->value()): ?> <?php echo $this->field('img_align')->value(); ?><?php endif; ?>" <?php echo $this->cssID; ?> style="background-image: url(<?php echo $this->field('image')->generate(); ?>);<?php if($this->field('height')->value()): ?>height:<?php echo $this->field('height')->value(); ?>px;<?php endif; ?>">
<div class="ce_headerimage_inside">
<?php if($this->field('headline')->value() || $this->field('subheadline')->value()): ?><div class="content"><?php endif; ?>
<?php if($this->field('headline')->value()): ?><?php echo $this->field('headline')->html(); ?><?php endif; ?>
<?php if($this->field('subheadline')->value()): ?><div class="subline"><?php echo $this->field('subheadline')->value(); ?></div><?php endif; ?>
<?php if($this->field('headline')->value() || $this->field('subheadline')->value()): ?></div><?php endif; ?>
</div>
</div>
<?php
if($this->field('mobile_height')->value())
$GLOBALS['TL_HEAD'][] = "<style>@media only screen and (max-width: 767px) {.ce_headerimage_" . $this->id . " {height:" . $this->field('mobile_height')->value() . "px!important;}}</style>"
?>