Conversation
supportAfter installing this plugin (which is great by the way!), the links in the media library have all broken. Everything works fine otherwise. What is happening is the plugin is adding the custom CNAME subdomain I have set in the program’s settings in addition to the old full URL to the images to make a non-existent full URL for each item in the library, i.e. http://img.example.com/http://www.example.com/wp-content/uploads/2015/01/file.jpg The link should be http://img.example.com/2015/01/file.jpg to display the images properly in the library as per the new configuration under the plugin. As best I can tell, it appears that the function set_cdn_path inside of lib/functions.php is where the problem is coming from. Any suggestions on how to fix this? If more information is needed please let me know. https://wordpress.org/plugins/rackspace-cloud-files-cdn/
I fixed this problem. It’s not ideal as it’s hardcoded based on the actual URL’s for my website and custom CNAME for the Rackspace cloud files container, but it works. I hope the developer can use this information to implement a permanent fix in a future upgrade because overall this plugin seems great. Here are the details for anybody else who might encounter this problem. The change I made assumes a custom CNAME of http://img.example.com is being used to point to the Rackspace cloud files container. In lib/functions.php around line 493, you will find this line: $attachment = str_replace($cur_attachment, $cdn_url.'/'.$new_attachment, $attachment); Immediately after this line, I added the following line (including a few lines of comments for explanation): // this function is returning media attachment urls as: // http://img.example.com/http://www.example.com/wp-content/uploads/2015/01/RetirementIncomePlan_PartTime.png // added the below line to strip out the extraneous URL $attachment = str_replace('http://www.example.com/wp-content/uploads/', '', $attachment);
I used your fix to get mine working… though the instrcution confused me a bit. I found the line 493 and the code. I had to make this edit to get it to work. $attachment = str_replace('myCDN-CNAME.r59.cf2.rackcdn.com', '/wp-content/uploads/', $attachment); then it worked… thanks so much for the fix.
I fixed this problem. It’s not ideal as it’s hardcoded based on the actual URL’s for my website and custom CNAME for the Rackspace cloud files container, but it works. I hope the developer can use this information to implement a permanent fix in a future upgrade because overall this plugin seems great. Here are the details for anybody else who might encounter this problem. The change I made assumes a custom CNAME of http://img.example.com is being used to point to the Rackspace cloud files container. In lib/functions.php around line 493, you will find this line: $attachment = str_replace($cur_attachment, $cdn_url.'/'.$new_attachment, $attachment); Immediately after this line, I added the following line (including a few lines of comments for explanation): // this function is returning media attachment urls as: // http://img.example.com/http://www.example.com/wp-content/uploads/2015/01/RetirementIncomePlan_PartTime.png // added the below line to strip out the extraneous URL $attachment = str_replace('http://www.example.com/wp-content/uploads/', '', $attachment);
I used your fix to get mine working… though the instrcution confused me a bit. I found the line 493 and the code. I had to make this edit to get it to work. $attachment = str_replace('myCDN-CNAME.r59.cf2.rackcdn.com', '/wp-content/uploads/', $attachment); then it worked… thanks so much for the fix.