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 srcset option to image_tag helper #29349
Conversation
r? @matthewd (@rails-bot has picked a reviewer for you, use r? to override) |
I think we should respect I like that this works with both a hash or an array-of-arrays; let's cover both of those in the tests. We definitely need to allow a value that's already a string to pass through safely, too, though -- people will already be using it in that way, and we don't want to break them. |
@matthewd sure, I'll be working on that, thanks for the feedback |
705e082
to
4a88bb3
Compare
@matthewd I think is ready again for review, could you take a look again?? |
@@ -237,6 +243,13 @@ def image_tag(source, options = {}) | |||
options[:alt] = options.fetch(:alt) { image_alt(src) } | |||
end | |||
|
|||
if options[:srcset] && !options[:srcset].is_a?(String) | |||
options[:srcset] = options[:srcset].map do |src, size| | |||
src_path = path_to_image(src, skip_pipeline: options.delete(:skip_pipeline)) |
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.
deleting the option inside the loop here seems like it won't do what you want
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.
yeah you are right
4a88bb3
to
57da123
Compare
57da123
to
43efae2
Compare
@matthewd could you take a look again over this PR?? |
Add srcset option to image_tag helper
Summary
Adding srcset option to image_tag in order to add Responsive Images.
Usage: