Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<picture> src (active source)

Is there a way to retrieve a <picture> element's currently used source in javascript without using the viewport width / pixel density?

Something similar to <select>:selected

Can anyone shed any light on this?

like image 848
minlare Avatar asked Jul 15 '26 12:07

minlare


1 Answers

The <picture> element is still experimental so I do not think there is an API to get the "active" source yet. I did however find the following issues for the <picture> spec expecting the element to have a currentSrc element.

https://github.com/ResponsiveImagesCG/picture-element/issues/223

currentSrc is the behaviour I also would have expected but currently it is simply not implemented in Chrome or FireFox.

like image 124
Blake Simpson Avatar answered Jul 18 '26 02:07

Blake Simpson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!