An implementation of the proposed <picture>
element. See original repo for something to actually use in production.
This web component uses the Polymer library.
- Make sure you have Polymers
platform.min.js
included in your page - Import component
<link rel="import" href="x-picture.html" />
- A picture element is contained inside a
<x-picture>
element - For each sized image specify as
<pic-src>
inside<x-picture>
<x-picture alt="A giant stone face at The Bayon temple in Angkor Thom, Cambodia">
<pic-src src="imgs/small.jpg" media="(min-width: 200px)"></pic-src>
<pic-src src="imgs/medium.jpg" media="(min-width: 400px)"></pic-src>
<pic-src src="imgs/large.jpg" media="(min-width: 800px)"></pic-src>
</x-picture>
Please don't use this, that's what the picturefill polyfill is for. This version is missing default image support and image swapping on resize.
I did a talk on Web Components and created a whole bunch of components to dog food the talk itself. See master repo web-components.