Report this

What is the reason for this report?

How to integrate new BPG Image format into Wordpress?

Posted on December 26, 2014

Latest wordpress, Server Ubuntu 14.10



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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>

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.