-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add support for lazy image loading #108
Conversation
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.
Hey @lunks, thanks for the PR and apologies for the delayed response here.
Initial thoughts: I think it would be worth adding extra documentation to guide users on how to integrate lazysizes into their app -- even if that just includes a link to an external guide. Since without it enabled, this feature would not work correctly.
Trying to follow what your peers did at react-imgix: https://github.com/imgix/react-imgix#lazy-loading is it ok to add a section to README similarly? An external guide could make sense, but I think it's out of the scope of the library or the PR. Most people as you can see on #60 already found a lazy-loading library suit to their causes, they just need imgix-rails to support the standard. |
Yes, I think an added section to the README (with example) would suffice 👍 |
Done @sherwinski, can you take a look? |
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.
Thanks for adding that @lunks.
Just a couple of small nitpicks to change. After that, I'd like to finish testing the feature out myself before merging.
Co-authored-by: sherwinski <sherwinhb@gmail.com>
Thanks for the suggestions, @sherwinski. It reads much better now. |
Hey @sherwinski any updates? |
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.
Hey @lunks,
I tested the feature and it works great 👍 I did find having to add lazysizes manually to my app a little awkward so I was curious if you knew of a way to ship this gem with the library baked in? An added benefit of that would be that we can control the version of the dependent library to ensure that it works as expected.
Like I mentioned in the other reply, I believe this would be out of the scope of the gem. See react-imgix, it tries to support it but be agnostic enough that you can use other libs that do a similar job. |
I see your point. In that case, the interface should match how we implemented it in react-imgix, which allows the user to set the attributes themselves. I like the proposed interface here but I think it would make more sense if we were going to ship it with a lazy loading library baked in. Right now, it feels a bit too in between being configurable and a full feature. To make the interface more generalized we should:
|
I disagree as most libraries besides lazysizes use this very same API. To list a few: I'll go forward with the proposed API but I think it's a worse API. This works for most cases with lazysizes and other similar plugins. People that need this (as stated on #60) would benefit from this as-is. |
@sherwinski done, let me know if you have any other requests. |
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.
Thanks a lot for your patience and working with me on this @lunks. This looks ready to merge now 👍
Hey @sherwinski could you please release a new gem version with this change? |
Description
Adds lazy support to
ix_image_tag
as described on #60. We need this in our project due to the amount of images being loaded on a single webpage, often from very bad network scenarios.Checklist: New Feature
chore(readme): fixed typo
. See the end of this file for more information.BREAKING CHANGE
in the body of the commit.Steps to Test
Remap any
img
attributes needed for the lazy-loading solution of your choice viaattribute_options
on an ix_image_tag:Related issue: #60