Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bootsified opened this issue Sep 15, 2017 · 1 comment

Comments

@bootsified
Copy link

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
Copy link
Owner

yaquawa commented Nov 8, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants