From 2405dd2433b8b014f8c441be31f509bb418b6501 Mon Sep 17 00:00:00 2001 From: tabuna Date: Sat, 30 Dec 2023 03:28:15 +0300 Subject: [PATCH] Change Cropper validation message --- resources/views/fields/cropper.blade.php | 2 +- src/Screen/Fields/Cropper.php | 36 ++++++++++++++---------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/resources/views/fields/cropper.blade.php b/resources/views/fields/cropper.blade.php index 74d891f85..f53edebef 100644 --- a/resources/views/fields/cropper.blade.php +++ b/resources/views/fields/cropper.blade.php @@ -15,7 +15,7 @@ data-cropper-groups="{{ $attributes['groups'] }}" data-cropper-path="{{ $attributes['path'] ?? '' }}" data-cropper-keep-original-type-value="{{ $keepOriginalType }}" - data-cropper-max-size-message-value="{{ __('The upload file is too large. Max size: {value} MB') }}" + data-cropper-max-size-message-value="{{ __($maxSizeValidateMessage) }}" >
diff --git a/src/Screen/Fields/Cropper.php b/src/Screen/Fields/Cropper.php index fc41a5c69..96893f28d 100644 --- a/src/Screen/Fields/Cropper.php +++ b/src/Screen/Fields/Cropper.php @@ -32,7 +32,7 @@ * @method Cropper maxFileSize($value = true) * @method Cropper storage($value = null) * @method Cropper staticBackdrop($value = false) - * @method Cropper keepOriginalType($keep = true) + * @method Cropper maxSizeValidateMessage($value = true) */ class Cropper extends Picture { @@ -47,19 +47,20 @@ class Cropper extends Picture * @var array */ protected $attributes = [ - 'value' => null, - 'target' => 'url', - 'url' => null, - 'width' => null, - 'height' => null, - 'minWidth' => 0, - 'minHeight' => 0, - 'maxWidth' => 'Infinity', - 'maxHeight' => 'Infinity', - 'maxFileSize' => null, - 'staticBackdrop' => false, - 'acceptedFiles' => 'image/*', - 'keepOriginalType' => false, + 'value' => null, + 'target' => 'url', + 'url' => null, + 'width' => null, + 'height' => null, + 'minWidth' => 0, + 'minHeight' => 0, + 'maxWidth' => 'Infinity', + 'maxHeight' => 'Infinity', + 'maxFileSize' => null, + 'staticBackdrop' => false, + 'acceptedFiles' => 'image/*', + 'keepOriginalType' => false, + 'maxSizeValidateMessage' => "The upload file is too large. Max size: {value} MB", ]; /** @@ -153,7 +154,12 @@ public function maxCanvas(int $size): self return $this; } - public function keepOriginalType(bool $keep = true) + /** + * Set whether to keep the original image type. + * + * @param bool $keep Whether to keep the original image type. + */ + public function keepOriginalType(bool $keep = true): self { $this->set('keepOriginalType', $keep);