From 09a7a776bb04650bd3c7df7da6b0476eae1e14f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Auswo=CC=88ger?= Date: Tue, 18 Nov 2014 12:28:32 +0100 Subject: [PATCH] Added compatibility for Contao 3.4 --- src/MadeYourDay/Contao/Module/Slider.php | 21 +++++++++++-------- templates/rsts_default.html5 | 26 +++++++++++++++++++++--- templates/rsts_default.xhtml | 26 +++++++++++++++++++++--- 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/src/MadeYourDay/Contao/Module/Slider.php b/src/MadeYourDay/Contao/Module/Slider.php index 583a635..c9c81fa 100644 --- a/src/MadeYourDay/Contao/Module/Slider.php +++ b/src/MadeYourDay/Contao/Module/Slider.php @@ -92,7 +92,7 @@ protected function compile() $file = new \File($files->path, true); - if (!$file->isGdImage) { + if (!$file->isGdImage && !$file->isImage) { continue; } @@ -248,7 +248,7 @@ protected function parseSlides($objSlides) : \FilesModel::findByUuid($slide['singleSRC']) ) && ($fileObject = new \File($file->path, true)) && - $fileObject->isGdImage + ($fileObject->isGdImage || $fileObject->isImage) ) { $meta = $this->getMetaData($file->meta, $objPage->language); $slide['image'] = new \stdClass; @@ -264,6 +264,7 @@ protected function parseSlides($objSlides) } if ($slide['videoURL'] && empty($slide['image'])) { + $slide['image'] = new \stdClass; if (preg_match( '(^ https?:// # http or https @@ -277,17 +278,19 @@ protected function parseSlides($objSlides) html_entity_decode($slide['videoURL']), $matches) ) { $video = $matches[1]; - $slide['image'] = new \stdClass; $slide['image']->src = '//img.youtube.com/vi/' . $video . '/0.jpg'; - $slide['image']->imgSize = ''; - $slide['image']->alt = ''; } else { - $slide['image'] = new \stdClass; // Grey dummy image $slide['image']->src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAJCAMAAAAM9FwAAAAAA1BMVEXGxsbd/8BlAAAAFUlEQVR42s3BAQEAAACAkP6vdiO6AgCZAAG/wrlvAAAAAElFTkSuQmCC'; - $slide['image']->imgSize = ''; - $slide['image']->alt = ''; + } + $slide['image']->imgSize = ''; + $slide['image']->alt = ''; + if (version_compare(VERSION, '3.4', '>=')) { + $slide['image']->picture = array( + 'img' => array('src' => $slide['image']->src, 'srcset' => $slide['image']->src), + 'sources' => array(), + ); } } @@ -298,7 +301,7 @@ protected function parseSlides($objSlides) : \FilesModel::findByUuid($slide['backgroundImage']) ) && ($fileObject = new \File($file->path, true)) && - $fileObject->isGdImage + ($fileObject->isGdImage || $fileObject->isImage) ) { $meta = $this->getMetaData($file->meta, $objPage->language); $slide['backgroundImage'] = new \stdClass; diff --git a/templates/rsts_default.html5 b/templates/rsts_default.html5 index 25f4f37..2c01102 100644 --- a/templates/rsts_default.html5 +++ b/templates/rsts_default.html5 @@ -7,7 +7,11 @@ images as $image): ?>
- imgSize ?> alt="alt ?>"> + + imgSize ?> alt="alt ?>"> + + insert('picture_default', $image->picture) ?> + href): ?> @@ -46,12 +50,28 @@
> - <?php echo $slide['image']->alt ?>> + + imgSize ?> alt="alt ?>" > + + insert('picture_default', $slide['image']->picture); + echo preg_replace('( +
> - imgSize ?> alt="alt ?>" > + + imgSize ?> alt="alt ?>" > + + insert('picture_default', $slide['image']->picture); + echo preg_replace('( + href): ?> diff --git a/templates/rsts_default.xhtml b/templates/rsts_default.xhtml index af4586d..8bf1ff7 100644 --- a/templates/rsts_default.xhtml +++ b/templates/rsts_default.xhtml @@ -7,7 +7,11 @@ images as $image): ?>
- imgSize ?> alt="alt ?>" /> + + imgSize ?> alt="alt ?>" /> + + insert('picture_default', $image->picture) ?> + href): ?> @@ -46,12 +50,28 @@
> - <?php echo $slide['image']->alt ?> /> + + imgSize ?> alt="alt ?>" /> + + insert('picture_default', $slide['image']->picture); + echo preg_replace('( +
> - imgSize ?> alt="alt ?>" /> + + imgSize ?> alt="alt ?>" /> + + insert('picture_default', $slide['image']->picture); + echo preg_replace('( + href): ?>