Problems with Loading lazy

Viewed 63

I'm trying to apply lazy loading to the images on my website when I apply it on a static image through a URL or assets, this attribute works perfectly

But, when I get images from my database and apply this attribute to it, for some reason, it doesn't work

Example of static image that does work

<img loading="lazy"  src="{{asset('img/minus.png')}}"/>

Example with dynamic images from my database that DOES NOT work

@foreach($product_all->product_images as $product_image_all)
    <img loading="lazy" id="image-{{$product_all->id}}" src="{{url('product/'.$product_image_all->image)}}">
@endforeach

My method to get the images from the database

public function getImage($filename) {
    $file = \Storage::disk('products')->get($filename);

    return new Response($file, 200);
}

Where is the fault? Why can't I get it to work?

1 Answers

Solved.

The problem was that I had to also put loading = "lazy" to the images that I was loading above because some were repeated

Related