We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Replacing image links on frontend to a CDN served image

How Do I?

nekorin's avatar
nekorin
29 posts
8 years ago
nekorin's avatar nekorin

Is there a way to automatically change the image links that is served on templates to their CDN versions?

Tried using the htaccess 301 redirect method but it is causing a substantial increase in page rendering time due to numerous image redirects in an image heavy site (around 20-40 images per page).

       
TJ Draper's avatar
TJ Draper
222 posts
8 years ago
TJ Draper's avatar TJ Draper

I use a multi-environment config and set a variable of {global:cdn_url}. In the config, I check the environment to see if it’s production. If it’s production, I set {global:cdn_url} to the cdn URL. If it’s not, I just set it to a forward slash. Then, for all my images, I use {global:cdn_url}/url/to/img.jpg or whatever. Often it looks like {global:cdn_url}{img:url}. Obviously this means having your CDN set up as a pull zone so that it pulls the image from your local server the first time then serves it from the CDN thereafter.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.