PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 1, 2022

[FIXED] how to display two image vertical slider in shopify product page

 July 01, 2022     shopify     No comments   

Issue

it shows only even image in slider odd images are hidden 0

I've assigned a variable in liquid and made odd and even classes I need one even and one odd in the image block class

was looking for the syntax on Google/Shopify cheatsheet/liquid Github wiki and can't seem to find anything that works

is this possible?

i was trying

  {% for media in product.media %}
  {% assign mod = forloop.index | modulo: 2  %}
  <div class="image-block">
    {%if mod == 0 %}

    <div class="even">
      <a  href="{{ media.preview_image | img_url: product_image_zoom_size, scale: product_image_scale }}"
         class=" product-single__thumbnail--{{ section.id }} even count-{{forloop.index}}"
         data-thumbnail-id="{{ section.id }}-{{ media.id }}">  <img class="product-single__thumbnail-image" src="{{ media.preview_image | img_url: 'large', scale: 2 }}" alt="{{ thumbnailAlt }}"></a>
    </div>

    {%endif%}


    {% for media in product.media %}

    {% assign mod2 = forloop.index | modulo: 2  %}

    {%if mod2 != 0 %}

    <div class="odd">
      <a  href="{{ media.preview_image | img_url: product_image_zoom_size, scale: product_image_scale }}"
         class=" product-single__thumbnail--{{ section.id }} odd count-{{forloop.index}}"
         data-thumbnail-id="{{ section.id }}-{{ media.id }}">  <img class="product-single__thumbnail-image" src="{{ media.preview_image | img_url: 'large', scale: 2 }}" alt="{{ thumbnailAlt }}"></a>
    </div>
    {% break %}

    {%endif%}

    {% endfor %}
  </div>

  {% endfor %}

</div>[enter image description here][1]

Solution

Simply use the same as into snapshot on the desired element where you want to apply the class using cycle. enter image description here

<div class="col px-2 px-lg-3 pb-3 pb-lg-4 {% cycle 'even','odd' %}">

and add the class on the front end like it. enter image description here

Let me know if the same clears your doubts regarding it?

update in to your code:

{% for media in product.media %}
  <div class="image-block">
    <div class="{% cycle 'even','odd' %}">
      <a  href="{{ media.preview_image | img_url: product_image_zoom_size, scale: product_image_scale }}"
         class=" product-single__thumbnail--{{ section.id }} even count-{{forloop.index}}"
         data-thumbnail-id="{{ section.id }}-{{ media.id }}">  <img class="product-single__thumbnail-image" src="{{ media.preview_image | img_url: 'large', scale: 2 }}" alt="{{ thumbnailAlt }}">
      </a>
    </div>
  </div>
{% endfor %}


Answered By - Onkar
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing