Skip to content

Commit

Permalink
Merge pull request #528 from mbenjamins/3.x
Browse files Browse the repository at this point in the history
Fix - upload image with uppercase extensions
  • Loading branch information
awcodes authored Aug 24, 2024
2 parents 30b6972 + fdfcc66 commit e43d3a2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion resources/views/components/tables/curator-column.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
$ring . ' ring-white dark:ring-gray-900' => $imageCount > 1,
])
>
@if (\Awcodes\Curator\is_media_resizable($item->ext))
@if (\Awcodes\Curator\is_media_resizable($item->type))
@php
$img_width = $width ? (int)$width : null;
$img_height = $height ? (int)$height : null;
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Forms/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function setUp(): void

$storeMethod = $component->getVisibility() === 'public' ? 'storePubliclyAs' : 'storeAs';

if (is_media_resizable($extension)) {
if (is_media_resizable($file->getMimeType())) {
if (in_array(config('livewire.temporary_file_upload.disk'), config('curator.cloud_disks')) && config('livewire.temporary_file_upload.directory') !== null) {
$content = Storage::disk($component->getDiskName())->get($file->path());
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function fullPath(): Attribute
protected function resizable(): Attribute
{
return Attribute::make(
get: fn () => is_media_resizable($this->ext),
get: fn () => is_media_resizable($this->type),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/MediaResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static function form(Form $form): Form
}),
]),
Forms\Components\Tabs\Tab::make(trans('curator::forms.sections.curation'))
->visible(fn ($record) => is_media_resizable($record->ext) && config('curator.tabs.display_curation'))
->visible(fn ($record) => is_media_resizable($record->type) && config('curator.tabs.display_curation'))
->schema([
Forms\Components\Repeater::make('curations')
->label(trans('curator::forms.sections.curation'))
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use Illuminate\Support\Str;

if (! function_exists('is_media_resizable')) {
function is_media_resizable(string $ext): bool
function is_media_resizable(string $type): bool
{
return in_array($ext, ['jpeg', 'jpg', 'png', 'webp', 'bmp']);
return in_array($type, ['image/jpeg', 'image/png','image/gif', 'image/webp', 'image/bmp']);
}
}

Expand Down

0 comments on commit e43d3a2

Please sign in to comment.