Prevent use of PNG media

Created: 26 Mar 2019, last update: 12 Sep 2020

How to prevent mistake use of PNG media files

It sometimes happens that a PNG media is used by accident with a relatively large file size in places where a JPG file with lossy compression would suffice.

Education and showing a warning will help. This is pretty easy to do in Sitecore with the rule engine without C# backend code.

Goto item: /sitecore/system/Settings/Rules/Content Editor Warnings/Rules

And create below an Content Editor Warning Rule. You can use a Fields rule the where the specific field compares to specific value and use this on the Extension field to look for PNG.

The warning look like this:

So that was easy. And of course I use JPG PNG images for this article, just because it's possible, or actually for screenshots, PNG is quite suitable.

For an automatic image optimizer for the Sitecore media library. see Dianoga