recently-viewed
recently-viewed copied to clipboard
Images are all broken
When using this script, the image URL is generated as
//cdn.shopify.com/s/files/1/0642/0537/products/100_4774_medium.JPG
which is broken. If I'm on the product page, the image URL (correct) is //cdn.shopify.com/s/files/1/0642/0537/products/100_4774.JPG.w560h847_medium.jpg?v=1409808948
This simply requires the match to be more specific so that if the string .jpg occurs in the middle of the string as well as the end, it matches only against the last one. So in the resizeImage function this
var match = src.match(/\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?/i);
becomes var match = src.match(/.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)($|?v=\d+)/i);