Today I will introduce another small feature of TinyMceEnhancements plugin. The functionality is used to automatically detect whether a browser supports the webp format.

TinyMceEnhancements serwer side webp support

Using extension

With this option, plug-ins such as imageSharp can change the image format from JPG to web.

The extension uses the GeneratedUrl event from the IContentUrlGeneratorEvents service, which is available in one of the newest versions of Optimizely packages.

When adding an image to TinyMCE, the DetectFormatOptimisation parameter is added to the query string and used in the event. In the event I’m checking if Accept request header contains “image/webp” format. When yes, then query string is extended with the format parameter.

To turn on the extension, in the TinyMceEnhancements we need to add: