From a5c7488649b07c54fde0ba20615cdd278db8c475 Mon Sep 17 00:00:00 2001 From: js42721 Date: Sat, 7 May 2016 00:15:14 -0400 Subject: [PATCH 1/2] Fix for issue #525 --- assets/timber.js.liquid | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/assets/timber.js.liquid b/assets/timber.js.liquid index 2726ef4e7..411b56840 100755 --- a/assets/timber.js.liquid +++ b/assets/timber.js.liquid @@ -207,6 +207,7 @@ timber.productPage = function (options) { // Selectors var $productImage = $('#ProductPhotoImg'), + $thumbImages = $('#ProductThumbs').find('a.product-single__thumbnail'); $addToCart = $('#AddToCart'), $productPrice = $('#ProductPrice'), $comparePrice = $('#ComparePrice'), @@ -218,7 +219,15 @@ timber.productPage = function (options) { // Update variant image, if one is set if (variant.featured_image) { var newImg = variant.featured_image, - el = $productImage[0]; + el = $productImage[0], + pattern = /[?&]v=([^&#]*)/, + v = pattern.exec(newImg.src)[1]; + $thumbImages.each(function() { + if (pattern.exec($(this).attr('href'))[1] === v) { + newImg.alt = $(this).find('img').attr('alt'); + return false; + } + }); Shopify.Image.switchImage(newImg, el, timber.switchImage); } @@ -265,7 +274,8 @@ timber.productImageSwitch = function () { timber.cache.$thumbImages.on('click', function(evt) { evt.preventDefault(); var newImage = $(this).attr('href'); - timber.switchImage(newImage, null, timber.cache.$productImage); + var newImageAlt = $(this).find('img').attr('alt'); + timber.switchImage(newImage, { alt: newImageAlt }, timber.cache.$productImage); }); } }; @@ -274,6 +284,7 @@ timber.switchImage = function (src, imgObject, el) { // Make sure element is a jquery object var $el = $(el); $el.attr('src', src); + $el.attr('alt', imgObject.alt); }; timber.responsiveVideos = function () { From 34037f3c09d3cc354d18f3777128c0439a7cc543 Mon Sep 17 00:00:00 2001 From: js42721 Date: Sat, 7 May 2016 01:01:26 -0400 Subject: [PATCH 2/2] Update timber.js.liquid --- assets/timber.js.liquid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/timber.js.liquid b/assets/timber.js.liquid index 411b56840..8d71e0e26 100755 --- a/assets/timber.js.liquid +++ b/assets/timber.js.liquid @@ -207,7 +207,7 @@ timber.productPage = function (options) { // Selectors var $productImage = $('#ProductPhotoImg'), - $thumbImages = $('#ProductThumbs').find('a.product-single__thumbnail'); + $thumbImages = $('#ProductThumbs').find('a.product-single__thumbnail'), $addToCart = $('#AddToCart'), $productPrice = $('#ProductPrice'), $comparePrice = $('#ComparePrice'),