-
Notifications
You must be signed in to change notification settings - Fork 4
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
thumb64() seems to enforce a square image; can it leave the aspect ratio the same as the original image? #4
Comments
I'll try to take a closer look at this over the next week or two. |
Even better would be if an image transform could be applied. |
This. ⬆️ Been breaking my head trying to get this to work: {% do imgAsset.setTransform( { width: 20, quality: 20 } ) %}
<img src="..." style="background-image: url('{{ image64( imgAsset, true ) }}');"> |
OK, I know it has been forever but I finally looked into this. I don't think this plugin is needed anymore. Craft v4 has the dataUrl function which does exactly what this plugin does.
If you wanted to use dataUrl with a transformation you could do something like this:
and it will produce a base64 encoding of the transformed version, keeping the aspect ratio. This even works with pre-defined image transformations...
So @proimage and @mprofitlich, what do you think? will the above work and we can retire this plugin? |
One issue I discovered recently (even with Craft's native EDIT: Also, |
I can explore caching...
Have you tried my example above? It does indeed work (just not as straightforward as you would expect.) There are two important pieces...
|
Not yet; I was basing my reply off of what I discovered (and Brandon confirmed) a while back, here: craftcms/cms#10108 I'll give your code a try though! :) EDIT: Just as a follow-up, the code you recommended doesn't work with remotely-stored images (eg. on DigitalOcean Spaces), even if I remove the |
@proimage correct, this only works for local files. |
The relevant code is this:
While the full-size header is 1920x1200px, the base64-encoded thumb is 40x40px. Ideally, it would be 40x25px. Is that possible?
The text was updated successfully, but these errors were encountered: