Browse code

Fix image slide backend preview

Benjamin Roth authored on07/06/2019 14:45:59
Showing1 changed files
... ...
@@ -31,14 +31,27 @@ class ContentSlickSliderImage extends \ContentElement
31 31
     {
32 32
       $return = '';
33 33
 
34
-      if ($this->singleSRC)
34
+      if ($this->multiSRC)
35 35
       {
36
-        $objFile = \FilesModel::findByUuid($this->singleSRC);
37 36
 
38
-        if ($objFile !== null && is_file(TL_ROOT . '/' . $objFile->path))
37
+        $source = \StringUtil::deserialize($this->multiSRC);
38
+        $objFiles = \FilesModel::findMultipleByUuids($source);
39
+
40
+        if ($objFiles !== null)
39 41
         {
40
-          $src = \System::getContainer()->get('contao.image.image_factory')->create(TL_ROOT . '/' . $objFile->path, array(100,40,'crop'))->getUrl(TL_ROOT);
41
-          $return = '<img src="'.$src.'">';
42
+          foreach ($objFiles as $file)
43
+          {
44
+            if (is_file(TL_ROOT . '/' . $file->path))
45
+            {
46
+              if (in_array($file->extension, array_map('trim', explode(',', \Config::get('validImageTypes')))))
47
+              {
48
+                $src = \System::getContainer()->get('contao.image.image_factory')->create(TL_ROOT . '/' . $file->path, array(66, 55, 'crop'))->getUrl(TL_ROOT);
49
+                $return .= '<img src="' . $src . '">'."\n";
50
+              } else if (in_array($file->extension, array_map('trim', array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv', 'm4a', 'mp3', 'wma', 'mpeg', 'wav', 'ogg')))) {
51
+                $return .= '<span>'.$GLOBALS['TL_LANG']['tl_content']['singleSRC'][0].': <a href="'.$file->path.'" target="_blank">'.$file->name.'</a></span>'."\n";
52
+              }
53
+            }
54
+          }
42 55
         }
43 56
       }
44 57