Support » Plugins » [Plugin: W3 Total Cache] Media Library Import – Subdirectory Bug

  • I was attempting to import the media library of an existing site, and although the import was working correctly, the URLs placed back into the article were broken. It seems to be an error when your site is not at the root of your domain.

    So what should have been:
    [SITE]/[SUBDIR]/wp-content/uploads/2010/03/image.jpg

    was coming through (missing slash):
    [SITE]/[SUBDIR]wp-content/uploads/2010/03/image.jpg

    My fix was to add this after line 690 in /lib/W3/Plugin/Cdn.php

    if (!preg_match('/\/$/', $site_url)) {
        $site_url .= '/';
    }

    http://wordpress.org/extend/plugins/w3-total-cache/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Can you please submit a bug submission report from the support tab of the plugin with access to your site/server?

    Unfortunately, the server I’m playing on now is firewalled into our local IPs only. I’ve actually switched the fix because it looks like when you retrieve the site_url, that trailing slashes are intentionally stripped. So here’s the new diff I’ve been using (on lib/W3/Plugin/Cdn.php):

    @@ -785,7 +785,7 @@
    
                                             $dst_basename = basename($dst);
                                             $dst_dirname = dirname($dst);
    -                                        $dst_url = sprintf('%s%s/%s', $site_url, $upload_url, $dst_basename);
    +                                        $dst_url = sprintf('%s/%s/%s', $site_url, $upload_url, $dst_basename);
    
                                             w3_mkdir($dst_dirname, 0755, ABSPATH);
    
    @@ -971,7 +971,7 @@
                         if (preg_match_all($regexp, $post_content, $matches, PREG_SET_ORDER)) {
                             foreach ($matches as $match) {
                                 $old_url = $match[2];
    -                            $new_url = sprintf('%s%s%s', $site_url, $upload_info['upload_url'], $match[5]);
    +                            $new_url = sprintf('%s/%s%s', $site_url, $upload_info['upload_url'], $match[5]);
                                 $post_content = str_replace($old_url, $new_url, $post_content);
    
                                 $results[] = array(

    Thanks, I’ll check it out.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: W3 Total Cache] Media Library Import – Subdirectory Bug’ is closed to new replies.