1

Is it possible to change the domain name when creating urls to the image:

file_create_url($file->uri)

I need the images to say they're coming from another domain, but I can't change the base_url, since we need to keep drupal accessible on origin.

Example

Origin: http://domain1.com/files...

When creating image urls, they will be http://domain2.com/files...

1
  • Yes. Never did, but CDN module does it all the time, so you can see what hooks it implements. If you will figure this out, please share!
    – Mołot
    Jan 29, 2014 at 8:08

1 Answer 1

1

Looking at file_create_url() I think it should be possible to pass in an absolute path, starting with /files... and then prefix the return value with your domain, protocol, whatever you need.

To handle that at a single location in code you can also use hook_file_url_alter().

Is it possible that you're looking for the CDN module?

2
  • You can use the CDN module in pull origin mode to do this, even if it isn't a real CDN. I do this to get static assets on cookie free domains.
    – mpdonadio
    Jan 29, 2014 at 3:03
  • Yes, I think the CDN module is what we're looking for, really appreciate the quick response on this!
    – Whnunlife
    Jan 29, 2014 at 4:02

Your Answer

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

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