One way you could do this is to test the mime type then pass a variable into template if statement, that is unless Drew has a simpler way to do this... Cause he's pretty awesome... :)
Unfortunately I can't compare paths as I'm using the density attribute to create the images, unless there is a way to access the density paths in a if statment?
One way you could do this is to test the mime type then pass a variable into template if statement, that is unless Drew has a simpler way to do this... Cause he's pretty awesome... :)
You can't, but that's an interesting idea. I'll see what I can do.
I found a bug with srcset in chrome where if the path/image for 1x and 2x are they same chrome displays the image but at 50%. Example here.
So my plan was to see if the paths are the same - then don't output srcset. This is mainly for SVGs.
You can compare paths but not mime types.
Unfortunately I can't compare paths as I'm using the density attribute to create the images, unless there is a way to access the density paths in a if statment?
If the images are different densities they'll have different paths - if they're the same density the same file should be reused.
The problem is with SVGs. As perch doesn't modify them the same path is outputted for both density paths.
Ah, of course. So if it's always the same file, does it matter which is used?
It doesnt matter which file is used no, the issue is with srcset bug in chrome as it displays the SVG as 50%.
For now I have set the width (along with max-width:100%) using
output="w"
which does the trick. I was just looking for a 'nicer' way of doing it.Ah ok.