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.

2 Answers 2


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.

  • which link PUT on Base URL for Static View Files and Base URL for User Media Files field ? Oct 16, 2019 at 7:16

But magento2 wont allow you to add any other URL from admin

it throws error message

"Invalid Base URL for User Media Files. Specify a URL or path that starts with placeholder(s): {{unsecure_base_url}}, and ends with "/". An empty value is allowed as well."

  • Make sure you add "/" at the end of the url. Nov 28, 2019 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.