-
-
Notifications
You must be signed in to change notification settings - Fork 508
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
retina support for the TimberImageHelper class #371
Comments
I agree this is a path to go. is the |
Yes, it is... But we could take this a step further and add 3 options in the global configuration, or using a filter:
This way we can be ready for whatever comes our way. Retina in 2 years may be 4x and not 2x, so why limit ourselves! :) |
Agreed, I don't think 2x is the end-of-the-line on this one. In terms of the interaction, the resize filter already has a bunch of parameters -- rather than append, I'm interested in add a fresh one, for example... <img src="{{ post.thumbnail.src | resize(600, 400) | retina(2) }}" /> For example, with srcset: <img src="{{ post.thumbnail.src }}" srcset="{{ post.thumbnail.src | retina(1) }} 1x,
{{ post.thumbnail.src | retina(2) }} 2x,
{{ post.thumbnail.src | retina(3) }} 3x,
{{ post.thumbnail.src | retina(4) }} 4x"> ... I'm with you on the global config but torn about the way to do it. Right now things are generally set through Timber::$properties, but I'm interested in a way of making that better before just throwing new properties (or filters) in there. |
I like it... 👍 |
I was actually able to do that semi-manually... https://github.com/presscodes/maera-bootstrap/blob/896e0a8da26bd8ef9ca394b7faa73ad72ac7d149/views/single-top.twig Though having this happen behind the scenes in Timber would make it a lot easier 😉 |
Hey @aristath -- I've got a branch with all the magic built-right-in: https://github.com/jarednova/timber/tree/371_retina You can now do... <img src="{{ post.thumbnail.src | retina }}" /> <img src="{{ post.thumbnail.src | retina(3) }}" /> <img src="{{ post.thumbnail.src | resize(400, 400) | retina }}" /> |
Seems to be working fine!! |
Awesome! I've thrown a bunch of tests at it and it's working great -- pulling into master.... |
closed by #377 |
This is a suggestion:
Adding retina support to the TimberImageHelper class would be relatively easy...
We'd have to basically create 2 files when we resize an image with width=W and Height=H:
The 2nd file would then have a resolution of 2Wx2H instead of WxH.
opinions?
The text was updated successfully, but these errors were encountered: