Ok I figured out how to do it manually for those interested:
Open
rackspace-cloud-files-cdn/lib/functions.php
On line 217 change
$_SESSION['cdn_url']
to
'http://images.example.com'
or whatever name you chose.
My suggestion is to make this an option so we can easily change through the admin interface.
Cheers
I made this change. Please let me know if this resolves your issue.
Doesn’t seem to work, I tried entering with
http and without, images still point to default url
How it works for me:
if (current_filter() == 'wp_get_attachment_url') {
if (file_exists(str_replace($upload_data['baseurl'], $upload_data['basedir'], $attachment)) !== false) {
return $attachment;
} else {
return str_replace($upload_data['baseurl'], 'http://images.tapebrain.com', $attachment);
}
} else {
preg_match_all('/\"(http|https).*?\/wp\-content\/.*?\/\d{4}+\/\d{2}+\/.*?\"/i', $attachment, $attachments);
foreach ($attachments[0] as $cur_attachment) {
// If local file does not exist, replace local URL with CDN URL
$cur_attachment = trim($cur_attachment, '"');
if (file_exists(str_replace($upload_data['baseurl'], $upload_data['basedir'], $cur_attachment)) === false) {
$new_attachment = str_replace($upload_data['baseurl'], 'http://images.tapebrain.com', $cur_attachment);
$attachment = str_replace($cur_attachment, $new_attachment, $attachment);
}
}
return $attachment;
}
not sure if the second one is needed though
Since the CDN URL is using a session variable, I had to make it update in the save settings function, I wasn’t doing that. Please update and let me know if this has resolved the issue.
Seems to work, thanks for the update 🙂
Great! Thanks for letting us know.
This request has been resolved. If you are willing, please rate and review the plugin.