-
Notifications
You must be signed in to change notification settings - Fork 15
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
Responsive images lookup can be triggered at any time #23
Conversation
var responsiveImages = document.querySelectorAll('img[data-fp-src]'); | ||
for (var i = 0; i < responsiveImages.length; i++) { | ||
construct(responsiveImages[i]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why just don't call constructAll()
here? It will do basically the same + it checks shouldConstruct(element)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this when I pulled the repo, but I do not know the correct way to call it.... I made my own hack to make it work... but I would rather use the official release.
@krystiangw I need sometimes for construct to be forced, and |
if (element.nodeName === 'IMG') { | ||
construct(element); | ||
} else { | ||
throw new Error('Passed object is not an image'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use throw new fp.FilepickerException()
here. Its simple filepicker libraryr wrapper for error object.
@krystiangw ok, done. Implementation of FilepickerException is far from perfect but for consistency reasons I'll use it. |
👍 |
Responsive images lookup can be triggered at any time
Rock on! |
Fixes #14
You can do two things with this API:
at any moment full lookup for images with
data-fp-src
will be performed.only this one image will be transformed to responsive.
Tested usage with masonry.js and unveil.js. Here are the samples: https://github.com/filepicker/filepicker-samples/tree/master/responsive_images