Browse code

Add Thumbnails to image slide CTE in Backend

Benjamin Roth authored on03/06/2018 11:09:15
Showing1 changed files
... ...
@@ -10,7 +10,6 @@
10 10
 
11 11
 namespace eSM_slick;
12 12
 
13
-
14 13
 /**
15 14
  * Front end content element slick slider start.
16 15
  */
... ...
@@ -24,6 +23,32 @@ class ContentSlickSliderImage extends \ContentElement
24 23
 	protected $strTemplate = 'ce_slick_slider_image';
25 24
 
26 25
   /**
26
+   * @return string
27
+   */
28
+  public function generate()
29
+  {
30
+    if (TL_MODE == 'BE')
31
+    {
32
+      $return = '';
33
+
34
+      if ($this->singleSRC)
35
+      {
36
+        $objFile = \FilesModel::findByUuid($this->singleSRC);
37
+
38
+        if ($objFile !== null && is_file(TL_ROOT . '/' . $objFile->path))
39
+        {
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
+        }
43
+      }
44
+
45
+      return $return;
46
+    }
47
+
48
+    return parent::generate();
49
+  }
50
+
51
+  /**
27 52
    * Generate the content element
28 53
    */
29 54
   protected function compile()