]> _ Git - fluidbook-toolbox.git/commitdiff
wait #4612 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 22 Jul 2021 15:55:07 +0000 (17:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 22 Jul 2021 15:55:07 +0000 (17:55 +0200)
app/Models/FluidbookTheme.php

index f31ef5b01be3f6ac954e4711d9cddb48f0ef10b3..b436996a5a134f69d5e9ad1647fcb9330996ee34 100644 (file)
@@ -44,6 +44,8 @@ class FluidbookTheme extends CubistMagicAbstractModel
 
         $this->addField('name', 'Text', __('Nom'), ['column' => true]);
 
+        $this->addField('preview', 'NoValue', __('Preview'), ['column' => true, 'column_type' => 'model_function', 'column_function_name' => 'getPreviewImage', 'column_limit' => -1]);
+
         $this->setSettingsFields();
     }
 
@@ -55,6 +57,7 @@ class FluidbookTheme extends CubistMagicAbstractModel
 
     public function setSettingsFields()
     {
+
         $this->addField([
             'name' => 'section_fonts',
             'type' => 'FormSection',
@@ -749,4 +752,9 @@ class FluidbookTheme extends CubistMagicAbstractModel
         $str = str_replace("s:8:\"\0*\0datas\"", 's:5:"datas"', $str);
         return unserialize($str);
     }
+
+    public function getPreviewImage()
+    {
+        return '<img src="data:image/jpeg;base64,' . base64_encode(file_get_contents(storage_path('/themes/' . $this->getIdValue() . '.jpg'))) . '" width="200" height="140" alt="" />';
+    }
 }