Open oxala opened 8 years ago
Hey @oxala, you are correct that we are missing support for the srcset
attribute and I think that would be a nice improvement. Any interest in submitting a Pull Request to add support for processing the srcset
attribute? If so, that would be awesome. The code changes would be limited to the following files:
srcset
attribute)path
argument to be an array of paths)If you are interested, I can definitely provide more guidance. Otherwise, we can add this feature to our backlog, and you can use the <lasso-resource>
tag as a workaround. Let me know what. Thanks for opening the issue.
To be fair - I've tried myself implement it before opening the issue. :-(
But if you would give me a bit more guidance in terms of how exactly i can process the srcset
value, i could definitely give it a go one more time.
After giving it some more thought we need to make it clear exactly what we want from Lasso. In theory, Lasso could generate the smaller images automatically if you provide the high resolution image. Is that something we want to consider?
The other issue is that parsing the srcset
might get kind of ugly to parse. In theory, we could require a JavaScript object similar to the following:
<lasso-img src="./images/camera.png" srcset={
"1x": "./images/camera@1x.png",
"2x": "./images/camera@2x.png"
}/>
Thoughts?
To be fair, i initially was thinking about very simple solution for case like:
<img src="image.png" srcset="image@2x.png">
Not specifying the ratio. It should cover most of the scenarios. And personally i never use anything else than just image for any retina screen.
But the object version looks decent as well, i think.
Generating smaller images - i think it's overkill. I do love automation, but i believe there should be a reasonable limit (especially, if at the moment nobody asked for it).
So, going back to srcset. I believe if we will think MVP, single string path should suffice for now. Unless you have some other analysis and know that i'm not the only one asked for this. :-)
In theory, Lasso could generate the smaller images automatically if you provide the high resolution image. Is that something we want to consider?
Maybe. Here's a possible implementation. Given this:
<lasso-img src="./path/to/img.png" width=100 />
<lasso-img>
could look at the image referenced by src
and based on the aspect-ratio, populate height
. src
. srcset
. @3x
, @4x
, and so on until the image was not large enough or up to a reasonable maximum.Perhaps it could be made to be opt-in and more explicit:
<lasso-img src="./path/to/img.png" width=100 @2x @3x @4x />
Or to avoid repetition:
<lasso-img src="./path/to/img.png" width=100 @2x-4x />
Another possible syntax:
<lasso-img src="./path/to/img.png" srcset(100x200, 2x-4x) />
<lasso-img src="./path/to/img.png" srcset(100w, 2x-4x) />
<lasso-img src="./path/to/img.png" srcset(200h, 2x-4x) />
I'm really missing the functionality to have
srcset
attribute within the <lasso-img> tag. Paths insidesrcset
attribute are not being processed by lasso. So, after generation i have something like:Could we have a processing on
srcset
paths as well?Please!