I've been trying to see which srcset
image my browser is using via the browsers developer tools, but apart from using the network tab to see which image it fetches i can't tell.
Using the network tab would usually be fine, but sometimes I've noticed that it will fetch 2 image versions at different sizes, this would happen if one break point is at 600 and another at 900 and the browser was currently at 750px wide.
(Ive tried this both on Chrome & FireFox, and it seems chrome will pull down both images in certain cases, but FireFox seems to only ever pull down one)
The reason I want to know is I'm interested if it pulls down two image srcset dose it swap between them automatically as i scale the browser window ? This is can't tell as by inspecting the element it just gives the raw html of the img
element, not the actual img srcset
option its using.
The sizes attribute determines the media condition that applies to the current device width (the first media condition that applies is selected). Then, the browser checks the srcset attribute to find the image that most closely matches the slot size determined by the sizes attribute.
srcset defines the set of images we will allow the browser to choose between, and what size each image is. Each set of image information is separated from the previous one by a comma.
Yes it's valid. The src is used as a fallback if the browser doesn't support srcset. However if you are using it just for retina stuff you don't really need to use picturefill. I tend to just let it degrade back to the normal src if the browser doesn't support srcset.
The image has a property currentSrc, you can log it or inspect it with several tools:
You will see an entry for currentSrc: with the actual image source.
I had problems with this today and I found that you can monitor the variable:
The live expression watches the current srcset of the img tag selected. It works with the img inside the picture tag too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With