Today I will introduce another small feature of TinyMceEnhancements plugin. The functionality is used to automatically detect whether a browser supports the webp format.
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:
1 2 3 4 |
services.Configure<TinyMceEnhancementsOptions>(options => { options.DetectFormatOptimization = true; }); |