Spatie media library responsive images
Could somebody please walk me through the process of creating responsive images using spatie media library plugin for filament on v3?
all of a sudden the live version of my blog decided to stop showing images on mobile devices so now i have to generate images with different sizes. this turned out to be a faulty css (my mistake)
Even though i refreshed the browser a few times on my phone nothing worked. Desktop version is doing fine.
So anyway, i decided to try the spatie media library plugin but already it seems impossible to comprehend off of just the documentation. š
https://filamentphp.com/plugins/filament-spatie-media-library
Filament
Spatie Media Library by Filament - Filament
Filament support for Spatie's Laravel Media Library package.
8 Replies
My form component looks like this:
Form component: https://filamentphp.com/plugins/filament-spatie-media-library#form-component
Generating responsive images: https://filamentphp.com/plugins/filament-spatie-media-library#generating-responsive-images
I learnt that you have to have a collection otherwise responsive images won't work.
Filament
Spatie Media Library by Filament - Filament
Filament support for Spatie's Laravel Media Library package.
Table component:
at first i couldn't display anything but later found out about the APP_ENV thing, so now i can show images. changed my variable to
the method on my Post model has all of the classes imported and i am utilizing just one conversion 'thumb':
Preparing my model:https://spatie.be/docs/laravel-medialibrary/v11/basic-usage/preparing-your-model
https://spatie.be/docs/laravel-medialibrary/v11/converting-images/defining-conversions
what i understand now is that, method is used to specify "conversions" and you can apply several methods to it, since i need to have several responsive images, i am using filament will then auto generate medium, large and extra large versions for my post images.
edit:
i actually had to add several conversions, for example:
Preparing your model | laravel-medialibrary
laravel-medialibrary
Defining conversions | laravel-medialibrary
laravel-medialibrary
and finally, the blade:
https://spatie.be/docs/laravel-medialibrary/v11/responsive-images/getting-started-with-responsive-images
what i understand from this is that i can use srcset to display the collection of responsive images which depending on the context the image should resize and have to reference the collection as well as the conversion as you can see.
Getting started with responsive images | laravel-medialibrary
laravel-medialibrary
what is the problem? several. actually.
1) one single image gets stored
within the route, no collection of images are created. i learnt that the desired outcome should output something like this:
this is the result on the html:
all i get is a blank srcset and can only grab the original image. š„³
also, no conversions nor responsive-images folders are created either.
2) the thumbnail doesn't preview my image
if i want to edit a post, the thumbnail preview on the form fails to load any image inside the thumbnail box. i really don't know what's going on here probably something outside the scope of filament??
so basically, that's it, thanks for reading this long ass post. i am usually not very good at deciphering plugins and get really anxious and skeptical about documentations as the end result almost never ever ever ever ever works out as they intended. probably because every situation is different than the controlled environment they propose, and i can understand that. i also understand there could be a few things im not considering before trying out these concepts, hope someone can help.
found a solution for creating folders:
https://stackoverflow.com/questions/78482222/laravel-media-library-responsive-images
basically add this to your env
by default the plugin processes image conversions using queues by default. if you do not have queues configured or running, then conversions and/or responsive images will not be generated.
Stack Overflow
Laravel media-library responsive images
I'm attempting to implement the responsive images feature of Laravel Spatie Media Library, but for some reason, it's not generating the images. I've tried registering a media conversion and applying
or run php artisan queue:work
or add this at the end of your registered media conversions