yaquawa / jquery.photoswipe

The jQuery plugin for PhotoSwipe
91 stars 35 forks source link

Regex overrides 'data-original-src-width' and 'data-original-src-height' #15

Open bootsified opened 7 years ago

bootsified commented 7 years ago

From the docs:

If the file name of src matches the pattern /(\d+)[*×x](\d+)/ (e.g. images/IMG_3012-1200x800.jpg), the plugin will takes width and height from the file name. (That way you don't need to specify the data-original-src-width and data-original-src-width).

Unfortunately, when using Craft CMS (and probably other cases), Craft adds the dimensions of the transform rules (which differ from the actual image dimensions) to the file name. For example, a transform that would resize the image to fit within a width of 1600px and a height of 900px, gets "1600x900" added to the filename. The actual image could be anything inside those dimensions.

So, even though I'm adding the images dimensions with data-original-src-width and data-original-src-height, it gets overridden by the regex code you have in the plugin and uses the wrong dimensions. It seems like the regex should only come in to play when no other option is available, or if it's enabled through the options. It's very possible I'm just doing something wrong, so if there is a workaround, please let me know. The only way I've been able to get it to work is by commenting out the regex part of the plugin.

Other than that, this sucker works like a charm. 👍

yaquawa commented 6 years ago

@bootsified Thanks for your feedback. The issue has now been fixed 👍