How to integrate new BPG Image format into Wordpress?

Posted December 26, 2014 2.9k views

Latest wordpress, Server Ubuntu 14.10

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

It’s still early days for the BPG format. So there isn’t much out there yet as far as built in support. The libbgp source includes a Javascript library that decodes the images browser side so that the user’s browser doesn’t need to support the format natively. From the project’s README file:

The Javascript decoder substitutes all the <img> tags with a source
having a .bpg extension with a <canvas> tag and decodes the BPG image
into it. Stylesheets are supported (the ‘id’ and 'class’ attributes
are preserved). The 'width’ and 'height’ attributes are supported only
with pixel units.

The image data is downloaded with the XMLHttpRequest object. So the
BPG images and the BPG Javascript decoder must be in the same domain
unless Cross-Origin Resource Sharing is used.

For the most basic support, you’d simply need to include the Javascript in your templates:

<script type="text/javascript" src="bpgdec.js"></script>