Skip to content

Commit

Permalink
Refactor media conversion methods in GalleryImage
Browse files Browse the repository at this point in the history
Updated media conversion methods to use modern syntax for better clarity and ease of maintenance. Removed the redundant use of Manipulations and updated composer dependency for `spatie/laravel-medialibrary` to version 11 to ensure compatibility with the latest features.
  • Loading branch information
daikazu committed Sep 23, 2024
1 parent 460da39 commit 2be4833
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"filament/forms": "^3.0",
"filament/tables": "^3.0",
"spatie/laravel-tags": "^4.5.1",
"spatie/laravel-medialibrary": "^10.12.2|^11",
"spatie/laravel-medialibrary": "^11",
"filament/spatie-laravel-media-library-plugin": "^v3.0.47",
"filament/spatie-laravel-tags-plugin": "^v3.0.47",
"livewire/livewire": "^v3.0.2"
Expand Down
14 changes: 7 additions & 7 deletions src/Models/GalleryImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Image\Enums\Fit;
use Spatie\Image\Exceptions\InvalidManipulation;
use Spatie\Image\Manipulations;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
Expand Down Expand Up @@ -50,15 +50,15 @@ public function registerMediaCollections(): void
*/
public function registerMediaConversions(?Media $media = null): void
{
// @phpstan-ignore-next-line
$this->addMediaConversion('thumb')
->fit(Manipulations::FIT_CROP, 100, 100)
$this->addMediaConversion('thumb')
->fit(fit: Fit::Crop,
desiredWidth: 100,
desiredHeight: 100)
->optimize()
->performOnCollections('gallery_images');

// @phpstan-ignore-next-line
$this->addMediaConversion('preview')
->crop(Manipulations::CROP_CENTER,
$this->addMediaConversion('preview')
->crop(
config('sortable-gallery.preview_image_size.width'),
config('sortable-gallery.preview_image_size.height'))
->width(config('sortable-gallery.preview_image_size.width'))
Expand Down

0 comments on commit 2be4833

Please sign in to comment.