Skip to content

Commit

Permalink
Enable Customizing imageResizeUpscale
Browse files Browse the repository at this point in the history
  • Loading branch information
yob-yob authored Nov 24, 2022
1 parent 59798aa commit d4fdc42
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/forms/resources/js/components/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default (Alpine) => {
imageResizeMode,
imageResizeTargetHeight,
imageResizeTargetWidth,
imageResizeUpscale,
isAvatar,
loadingIndicatorPosition,
locale,
Expand Down Expand Up @@ -89,6 +90,7 @@ export default (Alpine) => {
imageResizeTargetHeight,
imageResizeTargetWidth,
imageResizeMode,
imageResizeUpscale,
itemInsertLocation: shouldAppendFiles
? 'after'
: 'before',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
$imageResizeTargetHeight = $getImageResizeTargetHeight();
$imageResizeTargetWidth = $getImageResizeTargetWidth();
$imageResizeMode = $getImageResizeMode();
$imageResizeUpscale = $getImageResizeUpscale();
$shouldTransformImage = $imageCropAspectRatio || $imageResizeTargetHeight || $imageResizeTargetWidth;
@endphp
<div
Expand All @@ -36,6 +37,7 @@
imageResizeMode: {{ $imageResizeMode ? "'{$imageResizeMode}'" : 'null' }},
imageResizeTargetHeight: {{ $imageResizeTargetHeight ? "'{$imageResizeTargetHeight}'" : 'null' }},
imageResizeTargetWidth: {{ $imageResizeTargetWidth ? "'{$imageResizeTargetWidth}'" : 'null' }},
imageResizeUpscale: {{ $imageResizeUpscale ? "'{$imageResizeUpscale}'" : 'null' }}
isAvatar: {{ $isAvatar() ? 'true' : 'false' }},
loadingIndicatorPosition: '{{ $getLoadingIndicatorPosition() }}',
locale: @js(app()->getLocale()),
Expand Down
12 changes: 12 additions & 0 deletions packages/forms/src/Components/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ public function imageResizeMode(string | Closure | null $mode): static
return $this;
}

public function imageResizeUpscale(string | Closure | null $mode): static
{
$this->imageResizeUpscale = $mode;

return $this;
}

public function loadingIndicatorPosition(string | Closure | null $position): static
{
$this->loadingIndicatorPosition = $position;
Expand Down Expand Up @@ -184,6 +191,11 @@ public function getImageResizeMode(): ?string
return $this->evaluate($this->imageResizeMode);
}

public function getImageResizeUpscale(): ?string
{
return $this->evaluate($this->imageResizeUpscale);
}

public function getLoadingIndicatorPosition(): string
{
return $this->evaluate($this->loadingIndicatorPosition);
Expand Down

0 comments on commit d4fdc42

Please sign in to comment.