diff --git a/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php b/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php index 720605d9b..542ee0dad 100644 --- a/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php +++ b/src/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformer.php @@ -47,10 +47,12 @@ public function apply($value, $instance = null, $attribute = null) $instance = (object) [ $attribute => static::getUploadModelClass()::make([ 'file_name' => $value['file_name'] ?? $value['path'], - 'filters' => $value['filters'] ?? null, 'mime_type' => $value['mime_type'] ?? null, 'disk' => $value['disk'], 'size' => $value['size'] ?? null, + 'filters' => $value['filters'] ?? null, + 'width' => $value['width'] ?? null, + 'height' => $value['height'] ?? null, ]), ]; @@ -78,8 +80,10 @@ public function apply($value, $instance = null, $attribute = null) 'thumbnail', 'playable_preview_url', 'size', - 'filters', 'mime_type', + 'filters', + 'width', + 'height', ]; return array_merge( diff --git a/src/Form/Fields/Formatters/UploadFormatter.php b/src/Form/Fields/Formatters/UploadFormatter.php index ff6456a79..dc83e6f12 100644 --- a/src/Form/Fields/Formatters/UploadFormatter.php +++ b/src/Form/Fields/Formatters/UploadFormatter.php @@ -112,6 +112,8 @@ protected function normalizeFromFront(?array $value, ?array $formatted = null): 'mime_type' => $formatted['mime_type'] ?? $value['mime_type'] ?? null, 'disk' => $formatted['disk'] ?? $value['disk'] ?? null, 'filters' => $formatted['filters'] ?? $value['filters'] ?? null, + 'width' => $value['width'] ?? null, + 'height' => $value['height'] ?? null, ])->whereNotNull()->toArray(); } diff --git a/src/View/Components/Image.php b/src/View/Components/Image.php index 722744fdb..5d498678c 100644 --- a/src/View/Components/Image.php +++ b/src/View/Components/Image.php @@ -31,6 +31,8 @@ public function __construct( 'file_name' => $this->file['file_name'], 'disk' => $this->file['disk'] ?? null, 'filters' => $this->file['filters'] ?? null, + 'width' => $this->file['width'] ?? null, + 'height' => $this->file['height'] ?? null, ]); $this->disk = Storage::disk($this->fileModel->disk); $this->exists = $this->disk->exists($this->fileModel->file_name); diff --git a/tests/Unit/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformerTest.php b/tests/Unit/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformerTest.php index 19cd210b1..c2e3c5be8 100644 --- a/tests/Unit/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformerTest.php +++ b/tests/Unit/Form/Eloquent/Uploads/Transformers/SharpUploadModelFormAttributeTransformerTest.php @@ -268,6 +268,8 @@ 'disk' => 'local', 'filters' => [], 'mime_type' => 'image/png', + 'width' => 100, + 'height' => 100, ]; $transformer = (new SharpUploadModelFormAttributeTransformer())->dynamicInstance(); @@ -283,6 +285,8 @@ 'playable_preview_url' => null, 'filters' => [], 'mime_type' => 'image/png', + 'width' => 100, + 'height' => 100, ], $transformer->apply($uploadData, null, 'picture'), ); diff --git a/tests/Unit/Form/Fields/Formatters/EditorFormatterTest.php b/tests/Unit/Form/Fields/Formatters/EditorFormatterTest.php index 55641466d..ab7cf5a58 100644 --- a/tests/Unit/Form/Fields/Formatters/EditorFormatterTest.php +++ b/tests/Unit/Form/Fields/Formatters/EditorFormatterTest.php @@ -134,6 +134,8 @@ 'size' => 120, 'mime_type' => 'image/jpeg', 'disk' => 'local', + 'width' => 600, + 'height' => 600, ])), e(json_encode([ 'file_name' => 'data/Posts/1/doc.pdf', @@ -160,6 +162,8 @@ 'mime_type' => 'image/jpeg', 'filters' => null, 'id' => null, + 'width' => 600, + 'height' => 600, ], 'legend' => 'Legendary', '_locale' => null, @@ -175,6 +179,8 @@ 'mime_type' => 'application/pdf', 'filters' => null, 'id' => null, + 'width' => null, + 'height' => null, ], 'legend' => null, '_locale' => null, @@ -271,6 +277,8 @@ 'size' => 120, 'mime_type' => 'image/jpeg', 'disk' => 'local', + 'width' => 600, + 'height' => 600, ])) ); @@ -298,6 +306,8 @@ 'mime_type' => 'image/jpeg', 'filters' => null, 'id' => null, + 'width' => 600, + 'height' => 600, ], '_html' => sprintf(' My contentful content', $thumbnail, diff --git a/tests/Unit/Show/Fields/Formatters/TextFormatterTest.php b/tests/Unit/Show/Fields/Formatters/TextFormatterTest.php index e7eb42253..094b94a74 100644 --- a/tests/Unit/Show/Fields/Formatters/TextFormatterTest.php +++ b/tests/Unit/Show/Fields/Formatters/TextFormatterTest.php @@ -40,6 +40,8 @@ 'size' => 120, 'mime_type' => 'image/jpeg', 'disk' => 'local', + 'width' => 600, + 'height' => 600, ])), e(json_encode([ 'file_name' => 'data/Posts/1/doc.pdf', @@ -66,6 +68,8 @@ 'mime_type' => 'image/jpeg', 'filters' => null, 'id' => null, + 'width' => 600, + 'height' => 600, ], 'legend' => 'Legendary', '_locale' => null, @@ -81,6 +85,8 @@ 'mime_type' => 'application/pdf', 'filters' => null, 'id' => null, + 'width' => null, + 'height' => null, ], 'legend' => null, '_locale' => null,