Magento – Show Images from third-part site using AWS CDN

amazon-web-servicesimage

We are currently using AWS CDN to fetch images uploaded. In Magento admin, if I upload any image, it goes to CDN and then it show me the CDN path in <img src>.

Now, we have a third party content site from where we need to show images using CDN.

In Magento, if the image is normally uploaded from admin it shows path something like:

<img src="http://d56xhwfHe9rhq4.cloudfront.net/skin/frontend/package/theme/images/logo.gif" alt="" />

For ex: http://mysite.com/images/new-logo.gif resides on my third party content site.

And if the image is coming from third party content site, it currently shows like

<img src="http://thirdpart.com/media/images/new-logo.gif" alt="" />

which should be like below with CDN

<img src="http://d56xhwfHe9rhq4.cloudfront.net/media/images/new-logo.gif" alt="" />

How can I make CDN work with both normal magento image upload from admin as well as showing third party images with complete path ?

How can I achieve this ?

Thanks.

Best Answer

I think you could stay out of the Magento code completely - Cloud-front distributions can point to multiple origin servers:

Support for Multiple Origins - You can now reference multiple origins (sources of content) from a single Cloud-front distribution. This means that you could, for example, serve images from Amazon S3, dynamic content from EC2, and other content from third-party sites, all from a single domain name. Being able to serve your entire site from a single domain will simplify implementation, allow the use of more relative URLs within the application, and can even get you past some cross-site scripting limitations.

from: http://aws.amazon.com/blogs/aws/amazon-cloudfront-support-for-dynamic-content/

Related Topic