]> _ Git - cubist_cms-back.git/commitdiff
wait #5127 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Feb 2022 19:35:00 +0000 (20:35 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Feb 2022 19:35:00 +0000 (20:35 +0100)
src/resources/views/fields/dropzone_media.blade.php

index 768f07a7c11b78967b180981e509bd16770fb70c..0d072ea465ff0c7ddb18f397c5a19c04fb701d44 100644 (file)
@@ -1,6 +1,14 @@
 <?php
 $collection = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? [];
-
+$images = [
+    // Images
+    'jpeg', 'jpg', 'webp', 'gif', 'svg', 'png', 'avif',
+    // Videos
+    'mp4', 'webm', 'ogv', 'mkv',
+    // Other
+    'pdf'
+];
+$blank = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==';
 ?>
 @if(isset($entry))
     @include('crud::fields.inc.wrapper_start')
@@ -152,6 +160,8 @@ $collection = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ??
         @push('crud_fields_scripts')
             <?php
 
+
+
             $files = [];
             $filesrand = 'files_' . rand(1, 10000);
             foreach ($entry->getAllMedia() as $media) {
@@ -169,10 +179,18 @@ $collection = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ??
                     $full = '';
                 }
 
-                try {
-                    $thumb_url = $media->getUrl($field['thumb_conversion'] ?? null);
-                } catch (Exception $e) {
-                    $thumb_url = '';
+                $e = explode('.', $full);
+                $ext = mb_strtolower(array_pop($e));
+
+                if (in_array($ext, $images)) {
+                    try {
+                        $thumb_url = $media->getUrl($field['thumb_conversion'] ?? null);
+                    } catch (Exception $e) {
+
+                    }
+                }
+                if (!isset($thumb_url)) {
+                    $thumb_url = $blank;
                 }