To deal with this problem, we have built a Kentico plugin for our last project that will automatically optimise all the images the editor uploads to the Media Library. Source code can be found here at and is distributed via Nuget. This plugin is a fork from the original Dianoga for Sitecore, by Kamsar, that we have adapted for Kentico. It’s available for both Kentico 8.x and Kentico 9. It has also been approved in the Kentico Marketplace.
Installation is really easy and transparent, and it’s done through the Nuget Package Manager. You just need to look for “dianoga” in nuget.org and install your correspondent version: 8 or 9.
Or also via Nuget console:
Kentico 8.x: PM> Install-Package Dianoga.Kentico_8
Kentico 9: PM> Install-Package Dianoga.Kentico_9
Once the right package is installed, it already works without any other configuration. These are the changes in the source Project:
Web.configThese elements are added to the web.config file:
<section name="dianoga" type="Dianoga.Config.DianogaSection" />
<add type="Dianoga.Png.PngOptimizer, Dianoga" path="~/Dianoga Tools/PNGOptimizer/PNGOptimizerDll.dll" />
<add type="Dianoga.Jpeg.JpegOptimizer, Dianoga" path="~/Dianoga Tools/libjpeg/jpegtran.exe" />
A new folder is copied into the solution, “/Dianoga tolos”, that will host the libraries needed at runtime to perform the optimisations, and that needs to be deployed along with the whole website.
How it works
Dianoga will take care of automatically optimising all the images that are uploaded to the Media Library. To check this functionality, we will upload an image and we’ll check its size, before and after. Let’s take the previous image in this post as a sample:
If we upload it to the Media Library, we can see the reduction in size:
In the Event Log, the optimization is registered for each image uploaded:
Where we can see the optimization details:
This library is a must-have in all our Kentico libraries. If it’s been useful for you, please let us know! And if you think you can improve it, don’t hesitate and grab the repo from GitHub.