• Resolved LuxDelux

    (@luxdelux)


    Could you perhaps implement a simple field on the settings page where we can enter a custom files path in case we’re using a CNAME?

    Facebook has problems reading post images if the regular rackspace path is used so I made a simple CNAME eg. images.example.com

    Or please there me where I could change this in the php files manually so my files are read from this new CNAME?

    Cheers

    https://ww.wp.xz.cn/plugins/rackspace-cloud-files-cdn/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter LuxDelux

    (@luxdelux)

    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

    Plugin Author paypromedia

    (@paypromedia)

    I made this change. Please let me know if this resolves your issue.

    Thread Starter LuxDelux

    (@luxdelux)

    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

    Plugin Author paypromedia

    (@paypromedia)

    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.

    Thread Starter LuxDelux

    (@luxdelux)

    Seems to work, thanks for the update 🙂

    Plugin Author paypromedia

    (@paypromedia)

    Great! Thanks for letting us know.

    Plugin Author paypromedia

    (@paypromedia)

    This request has been resolved. If you are willing, please rate and review the plugin.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Modify path for CNAME’ is closed to new replies.