CDN for Media
Last updated
Last updated
The Media module in Orchard Core manages media files stored in the Media
folder. By default, media files are served directly from our CMS. However, when a CDN Base URL is configured, Orchard Core replaces the default URL with the CDN URL in the generated media links.
For example:
Default URL: http://localhost:5022/media/example.jpg
CDN URL: https://ocbc-cdn-demo.com/media/example.jpg
We can configure the CdnBaseUrl
dynamically in our Program.cs
of our core CMS project as demonstrated below.
To verify that the setting has been applied, we can visit the Administration UI to get the Media CDN URL, as shown in the following screenshot.
Orchard Core provides the IMediaFileStore
service to manage media files and generate URLs programmatically. For example:
The demo endpoint above will return the value "https://ocbc-cdn-demo.com/media/15-autumn-in-japan-body.jpg
".