You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the $post,there will be request featured containing image of the post,
i have used conversion to create the thumb of the image but i want to optimize the image also original one.
i am using $post->addMediaFromRequest('featured')->toMediaCollection('featured');
Where on the Post model $this->addMediaConversion('thumb') ->width(env('THUMB_WIDTH',150)) ->height(env('THUMB_HEIGHT',150)) ->performOnCollections('featured');
I find the thumb image is being optimized but not original one.
I could not even find on the documentation too.
The text was updated successfully, but these errors were encountered:
The medialibrary doesn’t make any changes to the original file. If you want to optimize the a file, you’ll have to do it yourself before adding it to the medialibrary.
Is there an event before adding the file to medialibrary?
I'd like to apply optimization on it, for example when using images given by URL. Would be nice to have an event allowing me to manipulate the file just before it is added to medialibrary.
NVM, I can work it on Spatie\MediaLibrary\MediaCollections\Events\MediaHasBeenAdded
That's a bit sad given that the lib can already do conversions, we would have to reinvent the wheel to do our own optimizations, it would be such a good addition if we could do
$this->addMediaConversion('original') ->width(500)->height(500)
->performOnCollections('featured')
->performOnOriginalImage(); // Or replaceOriginal()
On the $post,there will be request featured containing image of the post,
i have used conversion to create the thumb of the image but i want to optimize the image also original one.
i am using
$post->addMediaFromRequest('featured')->toMediaCollection('featured');
Where on the Post model
$this->addMediaConversion('thumb') ->width(env('THUMB_WIDTH',150)) ->height(env('THUMB_HEIGHT',150)) ->performOnCollections('featured');
I find the thumb image is being optimized but not original one.
I could not even find on the documentation too.
The text was updated successfully, but these errors were encountered: