Using REST API to serve media through a CDN
-
How can I get the WordPress REST api to respect W3 Total Cache settings for media?
If I use a CDN in W3 Total Cache and create a page with an image, then WordPress correctly serves the page with the image URL pointing to the image in the CDN. If I request the page through the REST API then I the image URL points to my WordPress server, not the CDN
e.g. Served directly from WordPress, the page contains
<p><img src=\"http:\/\/123456789.cloudfront.net\/wp-content\/uploads\/2017\/09\/test-300x298.jpg\" ...
but if I get the page from the REST API, then it contains:
"content": { "rendered": "<p><img src=\"http:\/\/myserver.com\/wp-content\/uploads\/2017\/09\/test-300x298.jpg\" ...
The server is on AWS. Ive set W3 Total Cache to push the media to an S3 bucket which is served by Cloudfront.
Is there any way to set this up to use the CDN URL?
- The topic ‘Using REST API to serve media through a CDN’ is closed to new replies.