Skip to content

Commit

Permalink
Change Cropper validation message
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Dec 30, 2023
1 parent 7e91ce7 commit 2405dd2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion resources/views/fields/cropper.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}"
>
<div class="border-dashed text-end p-3 cropper-actions">

Expand Down
36 changes: 21 additions & 15 deletions src/Screen/Fields/Cropper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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",
];

/**
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 2405dd2

Please sign in to comment.