Magento 2 Product Images – Serve Images Using URL Reference

cdnimage-uploadmagento2product-images

I want to serve images from an external CDN. This means:

  1. I don't want to store images on Magento's server or use its image cache
  2. I want to store image URLs in the database and use them to serve images directly in the browser via CDN
  3. I want to use transformations (width/300/height/300/foo.jpg) (this is not related to Magento, but I'm adding it here in case it complicates things)

Is Magento 2 prepared to serve images via URL out of the box, or does it require development work or changing anything in Magento's innards? If so, how much effort is required to configure Magento to serve images as such?

To be clear, I already have an Asset Management system with a CDN that furnishes image URLs. I want Magento to consume it.

Best Answer

You can tell Magento to use static files and media files from a CDN from the admin dashboard. Go to Stores > Configuration. Under the Web tab you can link the CDN in Base URL for Static View Files and Base URL for User Media Files. Don't forget to flush the cache after you change the settings.

Related Topic