Working with responsive image #2513
-
Hello there, greetings from Belgium ! I don't understand how to work with responsive images.. I have created a conversion as on the doc, but impossible to generate the multiple // My Model
public function registerMediaConversions(Media $media = null): void
{
$this->addMediaConversion('post_image')
->withResponsiveImages();
} // My Controller
public function index()
{
$posts = Post::where('is_active', true)
->get();
$post = $posts[0];
$media = $post->getFirstMedia('post_image');
dd($media->toHtml()); // Just to debug what I will have in my blade file
return view('pages.blog.index', ['posts' => $posts]);
} Here is the ouput <img src="http://127.0.0.1:8000/uploads/223/creation-logo-agence-web.jpg" alt="creation-logo-agence-web"> As you can see, it's not the multiple Of course I try to use it into my blade view, but it generates me the exact output. <!-- My Blade view -->
<div>
{{ $post->getFirstMedia('post_image') }}
</div> Any idea ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Responsive images and other conversions are queued, so make sure you're running a queue worker or they won't be generated. |
Beta Was this translation helpful? Give feedback.
-
I just found the error. I confused collections and conversions. $post->getFirstMedia($collection_name)->getUrl($conversion_name) |
Beta Was this translation helpful? Give feedback.
I just found the error.
I confused collections and conversions.
The write code is :