To implement ImageEngine’s image optimization for Kentico, you will first need to sign up for an ImageEngine account, if you do not already have one. During the signup process, you’ll be asked for the website domain where you intend to use ImageEngine and origin URL for the majority of the images. For more information about signing up, please refer to this article: Getting Started: Signup.
Once signed up, you will be issued a unique delivery address following this pattern: “aabbcc.cdn.imgeng.in.” Custom delivery addresses may also be made after the initial signup process is complete. For more information, see our article here: Delivery Address
Take note of your delivery address, as we will be needing it in the next step.
Adding code to rewrite image tags
Below, we assume that images-mysite.com.imgeng.in
is your delivery address.
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.imgeng.in/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.imgeng.in/media/{R:1}"/>
</rule>
</outboundRules>
</rewrite>
Note: Make sure to change images-mysite.com.imgeng.in in both places in the code above to your own information!
For more information on IIS rewrites and configuration examples, see the IIS Rewrite module documentation. (External Link)
CSS Background Images
If you are using background images in your CSS, you will need to use the absolute path with the CNAME domain in order for it to properly optimize.
After saving the settings, make sure to verify that images are loaded correctly through ImageEngine.
Comments
0 comments
Please sign in to leave a comment.