Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix - upload image with uppercase extensions #528

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -41,7 +41,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