system/modules/pct_theme_templates/templates/customelements/customelement_headerimage.html5 line 12

Open in your IDE?
  1. <?php 
  2. $GLOBALS['TL_CSS'][] = \Contao\Config::get('uploadPath').'/cto_layout/css/customelements/ce_headerimage.css|static';
  3. // responsive images
  4. $objFile \Contao\FilesModel::findByPk$this->field('image')->value() );
  5. if( $objFile !== null )
  6. {
  7.     $objPicture \Contao\Picture::create($objFile->path,deserialize$this->field('image')->option('size') ) );
  8.     $arrMediaQueries = array();
  9.     if( $objPicture !== null )
  10.     {
  11.         $arrPicture $objPicture->getTemplateData();
  12.         foreach($arrPicture['sources'] ?: array() as $data)
  13.         {
  14.             if( strlen($data['media']) < )
  15.             {
  16.                 continue;
  17.             }
  18.             $arrMediaQueries[] = '@media '.$data['media'].' { .ce_headerimage_'.$this->id.' { background-image:url('.$data['src'].') !important; } }';
  19.         }
  20.     }
  21.     if( count($arrMediaQueries) > )
  22.     {
  23.         $GLOBALS['TL_HEAD'][] = '<style>'.implode("\n",$arrMediaQueries).'</style>';
  24.     }
  25. }
  26. ?>
  27. <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; ?>">
  28.     <div class="ce_headerimage_inside">
  29.         <?php if($this->field('headline')->value() || $this->field('subheadline')->value()): ?><div class="content"><?php endif; ?>
  30.             <?php if($this->field('headline')->value()): ?><?php echo $this->field('headline')->html(); ?><?php endif; ?>
  31.             <?php if($this->field('subheadline')->value()): ?><div class="subline"><?php echo $this->field('subheadline')->value(); ?></div><?php endif; ?>
  32.         <?php if($this->field('headline')->value() || $this->field('subheadline')->value()): ?></div><?php endif; ?>
  33.     </div>
  34. </div>
  35. <?php 
  36. if($this->field('mobile_height')->value())
  37. $GLOBALS['TL_HEAD'][] = "<style>@media only screen and (max-width: 767px) {.ce_headerimage_" $this->id  " {height:" $this->field('mobile_height')->value() . "px!important;}}</style>"
  38. ?>