Last active
January 12, 2018 20:40
-
-
Save stefbowerman/bfbae945d1129f351304fd418baeb1f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% assign photo_main_dimension = '800x800' %} | |
| {% assign photo_zoom_dimension = '1600x1600' %} | |
| {% assign photo_thumb_dimension = '700x700' %} | |
| {% assign swatch_src_identifier = 'swt--' %} {% comment %} Used to find swatch images attached at the product level. We don't want to display them in the gallery. {% endcomment %} | |
| {% comment %} | |
| This block of logic loops through all product images and checks if we have at least 1 with valid alt text for *each* color option. | |
| {% endcomment %} | |
| {% assign variant_gallery_possible = false %} | |
| {% assign color_option_handle = '' %} | |
| {% for option in product.options_with_values %} | |
| {% assign option_name_downcase = option.name | downcase %} | |
| {% if option_name_downcase == "color" %} | |
| {% assign colors_with_images = 0 %} | |
| {% assign color_option_handle = 'position' | append: option.position %} | |
| {% for color in option.values %} | |
| {% assign downcase_color = color | downcase %} | |
| {% for image in product.images %} | |
| {% assign downcase_alt = image.alt | downcase %} | |
| {% if downcase_alt contains downcase_color %} | |
| {% unless image.src contains swatch_src_identifier %} | |
| {% assign colors_with_images = colors_with_images | plus: 1 %} | |
| {% break %} | |
| {% endunless %} | |
| {% endif %} | |
| {% endfor %} | |
| {% endfor %} | |
| {% if colors_with_images == option.values.size %} | |
| {% assign variant_gallery_possible = true %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use swatch alt text instead of filenaming
Change this line
to
and then change this line
to
and then make sure to update the
product-swatches.liquidsnippet to also use alt tags instead of filenames