How to Optimize Content with Kentico

Friday, September 14, 2018


By Joseph LoPresti, Solutions Engineer

Here at ScientiaMobile, we’ve had a couple of ImageEngine clients ask us how to enable ImageEngine for Kentico. So I’m going to walk you through what I’ve helped them with.

If you’re not familiar with Kentico, it’s a .Net-based all-in-one CMS, eCommerce, and online marketing platform. With a rich customizable feature set, companies of all sizes can take advantage of this platform. Kentico includes an open API, enabling integration into almost anything as well as an intuitive UI so users without development experience can work with the platform.  

By enabling ImageEngine on Kentico, (request a trial token or signup for ImageEngine here) you can ensure that your images are properly scaled and optimized across all devices and delivered through a global content delivery network.  Also, if you take advantage of the IIS rewrite module, you can easily update the image URL with your ImageEngine CNAME. Here is an example using the standard media path settings in Kentico.  You can easily customize this if you have a custom path.

Standard Media Path Setup in Kentico

In your web.config file within <system.webServer> add the following:

<rewrite>
    <outboundRules>
        <rule name="Rewrite Media to CDN" preCondition="IsHTML">
            <match filterByTags="Img" pattern="/getmedia/(.*)" />
            <action type="Rewrite" value="https://images.mysite.com/getmedia/{R:1}" />
        </rule>
        <rule name="Rewrite Media Files to CDN by path" preCondition="IsHTML">
            <match filterByTags="Img" pattern="/media/(.*)" />
            <action type="Rewrite" value="https://images.mysite.com/media/{R:1}"/>
        </rule>
    </outboundRules>
</rewrite>

 

Here is a link to the IIS Rewrite module documentation for more information on configuration: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

Images as Background

If you are using images as a background in your CSS, you will need to use the absolute path with the CNAME domain in order for it to properly optimize.  

There are also plugins in the marketplace that enable this functionality as well, but they do not always support the latest version of Kentico:

With these steps, you should be all set and ready to improve your website for the better. If you have any questions or concerns about getting started, you can always contact me at Joe@ScientiaMobile.com and use our free resources such as our ImageEngine Getting Started Guide.