WIP-Schnappschuss vor Migration 2026-09-28 (uncommittete Änderungen von master)
|
|
@ -1,27 +1,37 @@
|
||||||
{% if page.boxBody is not empty and page.boxBodyImage is defined and page.boxBodyImage %}
|
{% set image_url = null %}
|
||||||
|
{% set image_alt = page.title %}
|
||||||
|
{% set use_direct_url = false %}
|
||||||
|
|
||||||
|
{% if page.boxImageUrl is not empty %}
|
||||||
|
{% set image_url = page.boxImageUrl %}
|
||||||
|
{% set image_alt = page.travelProgram.title|default(page.title) %}
|
||||||
|
{% elseif page.boxBody is not empty and page.boxBodyImage is defined and page.boxBodyImage and page.boxBodyImage['thumb_url'] is defined %}
|
||||||
{% set image_url = page.boxBodyImage['thumb_url'] %}
|
{% set image_url = page.boxBodyImage['thumb_url'] %}
|
||||||
{% set image_alt = page.boxBodyImage['title'] %}
|
{% set image_alt = page.boxBodyImage['title']|default(page.title) %}
|
||||||
|
{% set use_direct_url = true %}
|
||||||
|
{% elseif page.travelProgram is not empty and page.travelProgram.previewImage is not empty %}
|
||||||
|
{% set image_url = 'uploads/travel_program/' ~ page.travelProgram.previewImage.fileNameWithExtension %}
|
||||||
|
{% set image_alt = page.title %}
|
||||||
|
{% elseif page.fewoLodging is not empty and page.fewoLodging.images is not empty and page.fewoLodging.images[0] is not empty %}
|
||||||
|
{% set image_url = '_uploads/images/' ~ page.fewoLodging.images[0].file %}
|
||||||
|
{% set image_alt = page.title %}
|
||||||
|
{% else %}
|
||||||
|
{% set image_url = asset('/bundles/app/images/no-picture.png') %}
|
||||||
|
{% set image_alt = 'Kein Vorschaubild vorhanden' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if image_url and not use_direct_url %}
|
||||||
|
{% set image_url = box_image_web_path(image_url) %}
|
||||||
|
{% if is_absolute_url(image_url) %}
|
||||||
|
{% set use_direct_url = true %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if use_direct_url %}
|
||||||
<div class="img-background lozad" data-background-image="{{ image_url }}" style="background-image:url({{ asset('images/placeholder-image.png') }});"></div>
|
<div class="img-background lozad" data-background-image="{{ image_url }}" style="background-image:url({{ asset('images/placeholder-image.png') }});"></div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if page.boxImageUrl is not empty %}
|
<div class="img-background lozad" data-background-image="{{ image(image_url|trim('/')).cropResize(360).guess(70) }}" style="background-image:url({{ asset('images/placeholder-image.png') }})"></div>
|
||||||
{% set image_url = page.boxImageUrl %}
|
|
||||||
{% set image_alt = page.travelProgram.title|default(page.title) %}
|
|
||||||
{% elseif page.travelProgram is not empty and page.travelProgram.previewImage is not empty %}
|
|
||||||
{% set image_url = 'uploads/travel_program/' ~ page.travelProgram.previewImage.fileNameWithExtension %}
|
|
||||||
{% set image_alt = page.title %}
|
|
||||||
{% elseif page.fewoLodging is not empty and page.fewoLodging.images is not empty and page.fewoLodging.images[0] is not empty %}
|
|
||||||
{% set image_url = '_uploads/images/' ~ page.fewoLodging.images[0].file %}
|
|
||||||
{% set image_alt = page.title %}
|
|
||||||
{% elseif page.boxBody is not empty and page.boxBodyImage is defined and page.boxBodyImage %}
|
|
||||||
{% set image_url = page.boxBodyImage['thumb_url'] %}
|
|
||||||
{% set image_alt = page.boxBodyImage['title'] %}
|
|
||||||
{% else %}
|
|
||||||
{% set image_url = asset('/bundles/app/images/no-picture.png')%}
|
|
||||||
{% set image_alt = 'Kein Vorschaubild vorhanden' %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="img-background lozad" data-background-image="{{ image(image_url|trim('/')).cropResize(360).guess(70) }}" style="background-image:url({{ asset('images/placeholder-image.png') }})"></div>
|
|
||||||
<noscript>
|
<noscript>
|
||||||
<img width="234" data-url="{{ image_url }}" height="180" src="{{ image(image_url|trim('/')).cropResize(360).guess(70) }}" class="img-responsiv img-responsiv-item" style="">
|
<img width="234" data-url="{{ image_url }}" height="180" src="{{ image(image_url|trim('/')).cropResize(360).guess(70) }}" class="img-responsiv img-responsiv-item" style="">
|
||||||
</noscript>
|
</noscript>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,9 @@ class AppExtension extends \Twig_Extension
|
||||||
'get_base_url' => new \Twig_SimpleFunction('get_base_url', [$this, 'getBaseUrl']),
|
'get_base_url' => new \Twig_SimpleFunction('get_base_url', [$this, 'getBaseUrl']),
|
||||||
'get_file_last_time' => new \Twig_SimpleFunction('get_file_last_time', [$this, 'getFileLastTime']),
|
'get_file_last_time' => new \Twig_SimpleFunction('get_file_last_time', [$this, 'getFileLastTime']),
|
||||||
'get_content_by_slug' => new \Twig_SimpleFunction('getContextBySlug', [$this, 'getContentBySlug']),
|
'get_content_by_slug' => new \Twig_SimpleFunction('getContextBySlug', [$this, 'getContentBySlug']),
|
||||||
'get_info_by_slug' => new \Twig_SimpleFunction('getInfoBySlug', [$this, 'getInfoBySlug'])
|
'get_info_by_slug' => new \Twig_SimpleFunction('getInfoBySlug', [$this, 'getInfoBySlug']),
|
||||||
|
'box_image_web_path' => new \Twig_SimpleFunction('box_image_web_path', [$this, 'boxImageWebPath']),
|
||||||
|
'is_absolute_url' => new \Twig_SimpleFunction('is_absolute_url', [$this, 'isAbsoluteUrl']),
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -151,6 +153,31 @@ class AppExtension extends \Twig_Extension
|
||||||
{
|
{
|
||||||
return Util::getBaseUrl();
|
return Util::getBaseUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wandelt Mediathek-URLs (CRM) in einen web/-relativen Pfad für den image()-Filter um.
|
||||||
|
*/
|
||||||
|
public function boxImageWebPath($url)
|
||||||
|
{
|
||||||
|
if (empty($url)) {
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('#^https?://mein\.sterntours\.(de|test)/storage/files/(.+)$#i', $url, $matches)) {
|
||||||
|
return 'media/' . $matches[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('#^https?://#i', $url)) {
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ltrim($url, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isAbsoluteUrl($url)
|
||||||
|
{
|
||||||
|
return is_string($url) && preg_match('#^https?://#i', $url);
|
||||||
|
}
|
||||||
public function formField($form, $label = null, $opt = null)
|
public function formField($form, $label = null, $opt = null)
|
||||||
{
|
{
|
||||||
$this->template = $this->environment->loadTemplate('::default/form/helpers.html.twig');
|
$this->template = $this->environment->loadTemplate('::default/form/helpers.html.twig');
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |