• nathan

    (@nathan)


    Inserting images from the media library that have been uploaded to Amazon S3 and then removed from the local server results in broken image links, I fixed this issue by patching the file sb_root_relative_urls.php.

    Changed This:

    static function root_relative_url($url, $html) {
    
            //If urls already start from root, just return it
            if ($url[0] == "/") return $html;
    
            $p = parse_url($url);
            $root = $p['scheme'] . "://" . $p['host'];
            $html = str_ireplace($root, '', $html);
            return $html;
        }

    To This:

    static function root_relative_url($url, $html) {
    
            //If urls already start from root, just return it
            if ($url[0] == "/") return $html;
    
    		// Don't strip URL data for images stored on external cloud servers such as Amazon S3...
    		if ( self::dynamic_absolute_url($url) ) {
    			$root = '';
    		}
    		else{
    			$p = parse_url($url);
    			$root = $p['scheme'] . "://" . $p['host'];
    		}
    
            $html = str_ireplace($root, '', $html);
            return $html;
        }

    Otherwise this is the single best plugin for WP…

    Cheers.

    https://www.ads-software.com/plugins/root-relative-urls/

  • The topic ‘This plugin conflicts with Amazon S3 and Cloudfront plugin’ is closed to new replies.