UprootLabs / poly-flif

:camera: A poly-fill for the FLIF image format.
https://uprootlabs.github.io/poly-flif/
Other
244 stars 11 forks source link

Support rendering to CSS background image #21

Closed hrj closed 8 years ago

hrj commented 8 years ago

Idea credit: @TheJaredWilcurt

If an element has data-polyflif-bg attribute, then its value should be taken as a source URL, fetched, decoded, and rendered to an offline canvas.

The offline canvas can then be converted to a blob URL and assigned to element.style.backgroundImage.

This is already possible with the current API; demo: https://jsfiddle.net/5v4t424f/12/

.. but would be nice to support out of the box.

Note: toBlob() is a new API (requires Chrome 50, IE10), but is easily poly-fillable as shown on the MDN page.