Jump to content

Swiper integration


prcwest

Recommended Posts

Hello 

I integrated  swiper into the classic theme. Im using lazy load for two swiper carousels on my homepage ( featured products & new products).

Swiper is using the data-src image tag to lazy load. everything is working great. problem i am running into is, if i use the data-src img tag, the images are not loaded in the category pages. the solution for this i used is the following:

<img {if $page.page_name=='index' } data-src="{$product.cover.bySize.home_default.url}" class="swiper-lazy" {else} src="{$product.cover.bySize.home_default.url}" alt="{if !empty($product.cover.legend)}{$product.cover.legend}{else}{$product.name|truncate:30:'...'}{/if}"
  data-full-size-image-url="{$product.cover.large.url}" {/if}>{if $page.page_name == 'index'}
<div class="swiper-lazy-preloader swiper-lazy-preloader-black"></div>{/if}
</a>
{else}
<a href="{$product.url}" class="thumbnail product-thumbnail">
            <img
              src = "{$urls.no_picture_image.bySize.home_default.url}"
            >

As i said, its working fine and  just wondering if  this is the correct solution or is there maybe another better way. Any input would be greatly appreciated 

Thank you in advance.

Best regards

Pascal

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...