-
Notifications
You must be signed in to change notification settings - Fork 7
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 image helpers #19
Comments
@dbernheisel I think these are all great ideas and IMHO, I think they'd make great additions to Brady. I'd much rather use Brady for all my basic frontend needs than to pull in a multitude of options. For the I think something more descriptive for the |
@drapergeek More descriptive name or docs for |
This is what I get for skimming...you're totally correct. Forgive my ignorance, I haven't been doing frontend work recently. Is the |
Here's a good small explanation of the difference: https://dev.to/jessefulton/explain-htmls-img-srcset-vs-picture-tag-like-im-five-167p Both can accomplish "responsive images", but have some different uses. tldr:
|
🆒 |
Effort outlined in #19 Introduce a `Brady.data_uri(image_path)` function that will base64 encode the image and output a data uri compatible with `<img src="x">`. The function will emit warnings when it is inlining images larger than 2048 bytes (after base64 encoding) by default, but can be configured in Mix to have a different threshold.
I have an interest in implementing responsive image helpers for a project I'm on. I'd be happy to contribute them to Brady instead of making my own library. Here are my thoughts and couple steps to get there.
I'll be happy to contribute these functions in separate PRs, as they'd be helpful by themselves for others.
data_uri
helper to inline images.srcset
attribute helper.picture_tag
helper.The idea is that if my
/assets/images
folder contains original images, and my asset pipeline has a task that will produce responsive images from those original images and place them in/priv/static/images
with some sort of naming convention, then I can refer to them in Phoenix templates. Right now, it's really tedious to use responsive images in Phoenix, as I have to write content tags for each format and version for each image on the page.Here are some function docs to help illustrate how they could work:
The text was updated successfully, but these errors were encountered: