1

I have a canvas application that I've built. It works great except for one problem. When I'm logged in, the URL to the images are all local urls like such:

http://example.com/image.jpg

When logged out, because W3 Total Cache has the CDN option configured, they all appear to link to a foreign domain, Cloudfront:

http://example.cloudfront.net

Now, normally this is terrific for obvious reasons, but when an image from a foreign domain is introduced to a canvas it create a security violation known as tainting the canvas which disabled many of the functions that my app uses.

So the question is quite simple: How do I fetch the local version of the image URL to output in the source tag?

Additional Notes:

  1. The image is uploaded to an "image" field generated from Advanced Custom Fields Pro. It is set to return the image URL. But when set to return the image array, it is still rewritten to the CDN.

  2. I have attempted to run a string replace on the image URL immediately before echoing it, but it doesn't seem to have any effect:

Here's an example:

foreach($fields['design_layers'] as $design_layer):
    $image_link = str_replace('http://example.cloudfront.net','http://example.com',$design_layer['design_layer']);
    echo '<img src="'.$image_link.'" />';
endforeach;
4

0 回答 0