Replies: 8 comments 2 replies
-
I have same problem to generate responsive image in vue.js |
Beta Was this translation helpful? Give feedback.
-
I have this exact same problem... I would like to query for the responsive srcset on demand via an API route for my vue.js I am generating the responsive images like so:
The responsive images are successfully generated, however, when I query for the Media collection with getMedia(), the media objects returned do not contain any data in the responsive_images array:
|
Beta Was this translation helpful? Give feedback.
-
It seems default image when there is no image is also not working with media library when using vue.js. Getting a Call to a member function getUrl() on null |
Beta Was this translation helpful? Give feedback.
-
same issue here |
Beta Was this translation helpful? Give feedback.
-
I had a similar problem whilst creating a livewire/alpinejs slideshow. The problem is that the blade component My help was in the source of media-library's own blade templates found in their vendor/spatie/laravel-media-library/ folders. It may help someone.
|
Beta Was this translation helpful? Give feedback.
-
U can use this : $media = $yourModel->getFirstMedia();
$responsiveImg = $media('conversionName'); |
Beta Was this translation helpful? Give feedback.
-
For a vuejs/inertia app i used this : $gallery = $model->getMedia('gallery')->map(function($media) {
return [
'id' => $media->id,
'thumb_url' => $media->getUrl('thumb'),
'responsive' => $media('responsive')->toHtml(),
'alt' => '',
'caption' => '',
];
}); The key is here : |
Beta Was this translation helpful? Give feedback.
-
Nice one @mchev !
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I been studying the docs to figure out how to use responsive images with vue.js.
https://docs.spatie.be/laravel-medialibrary/v8/responsive-images/getting-started-with-responsive-images/
This is the blade example
My greyscale responsive image
{{ $media('my-conversion') }}Yet have not figure out how to get the responsive images to display from the Get request with Axios.
Beta Was this translation helpful? Give feedback.
All reactions