For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Saturday, November 30, 2024

Passing value in Shopify snippets and use it

Passing value in Shopify snippets and use it

You are working on Shopify project with a snippet. In that snippet you want pass value as per your need. So how can you achieve it ?

Let assume that you will use a snippet "rimg-a.liquid" in other liquid file and want to use as below. You want to pass imgurl, class and fetch value.

================================================

content of any liquid file or theme.liquid file in where you want to use rimg-a.liquid snippet file

include 'rimg-a',
        imgurl: 'URl-IMAGE',
        class: 'feature-mobile',
        fetch: 'yes'

================================================

content of rimg-a.liquid file

  <img  {% if fetch != blank %} fetchpriority="high" decoding="async" {% endif %} 
    {% if imgurl != blank %}
        src="{{ imgurl | split:'?' | first | replace: '2078x2233','390x419' }}"
    {% endif %}
    {% if class != blank %}class="{{ class }}"{% endif %}
  >

 

 

 

 

 

Share:

0 comments:

Post a Comment

Image Zoom Hover Effect

 Image Zoom Hover Effect                                                                   Image zoom hover out effect                      ...

Ads Inside Post

Powered by Blogger.

Arsip