Use in Blade
Sow all files with Image filter
@foreach(sGallery::all() as $item)
@if(sGallery::hasImage($item->type))
<a class="swiper-slide" @if(trim($item->link))href="{{$item->link}}"@endif>
<div class="container">
<img loading="lazy" class="intro__img" src="{{$item->src}}" alt="{{$item->alt}}" width="1440" height="456">
<div class="intro__inner">
<div class="h1__title">{{$item->title}}</div>
<p class="intro__text">{{$item->description}}</p>
@if(trim($item->link_text))<div class="btn background__mod">{{$item->link_text}}</div>@endif
</div>
</div>
</a>
@endif
@endforeach
Sow all files with YouTube filter
@foreach(sGallery::all() as $item)
@if(sGallery::hasYoutube($item->type))
<div class="item">
<div class="video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/{{$item->file}}" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<p>{{$item->title}}</p>
</div>
@endif
@endforeach
Sow all product files
@foreach(sGallery::all('product', $product->id) as $item)
<div class="swiper-slide">
<a class="js-trigger-fancybox" href="{{$item->src}}" data-fancybox="product-gallery">
<img loading="lazy" src="{{$item->src}}" width="440" height="440" />
</a>
</div>
@endforeach
Sow first product file
You can use it for an example cover.
@php($item = sGallery::first('product', $product->id))
<img loading="lazy" src="{{$item->src}}" alt="{{$item->alt}}" width="440" height="440" />
Gallery items if blocks are used
In the event that you need more than one gallery per page, you will use blocks.
In this case, you must use the block()
method to output units from the selected gallery block:
@foreach(sGallery::block('cinema') as $item)
@if(sGallery::hasYoutube($item->type))
<lite-youtube videoid="{{$item->file}}"></lite-youtube>
@endif
@endforeach