Support » Plugins » [Plugin: W3 Total Cache] image gallery not working with cdn enabled

  • Resolved sqlwiz


    I’m working on implementing the latest w3tc in a wpmu site and it looks great.

    The CDN Type is “Origin Push / Self-hosted (File Transfer Protocol Upload)”. The “export media library to CDN” option ran fine. Most media is working fine with CDN enabled.

    We’ve got a number of posts that use the [gallery] tag. Images are uploaded using the “Add media:” option, “Link URL” is set to “None”. “File URL” type links are generated by default for gallery items when viewing the site.

    The galleries work with the CDN disabled, but stop working with the CDN enabled.

    The file urls are a mess by default and I suspect the Apache server running wordpress is fixing them and that the asset host does not know what to do with the urls. The urls have the following format:

    I really cannot add file urls manually to all the gallery images. Can you suggest a way to deal with this problem?

Viewing 15 replies - 1 through 15 (of 17 total)
  • The plugin cannot automatically upload your gallery changes. You need to make sure that the path to your gallery files is added to the custom files list and that you export those to CDN. Then you should see them work.

    Hi Frederick,

    I don’t believe we’ve made any changes. Having said that, I’ve just seen different (normal) behavior in another install, so I’ll have to research the current settings and plugins.


    @frederick Townes: Hi sir, I finally managed to export my gallery to the CDN. Now my problem is that I blog with Windows Live Writer.

    How do I set Windows Live Writer to upload images of new blog posts to the CDN?

    My CDN is
    Thanks a lot!

    To be honest, I’m not sure how to support this case because I’ve never used Live Writer. Does Live Writer work natively with the Media Library?

    It works natively with Windows Live Writer such that post images land in the wp-content/upload folder but there’s an option to have it FTP the images to any other location which is why I’m kind of wondering how to set it up without having to export the media gallery after each new post. Thanks anyway 😉

    Unfortunately, without auto-upload I cannot support this case.

    To wrap up the initial issue for anyone with a similar problem.

    We run wp-admin on a different server behind the firewall, therefore the file path stored in the attachment post meta data does not match the value of basedir for the blog when accessed by an external viewer.

    That is why we are seeing strange urls in the gallery at run time, but not in the admin. In addition, WordPress apparently fixes the urls when serving the files, since this was not a problem until we enabled the cdn. But it is not a w3-total-cache problem.

    The fix we implemented was a filter for “wp_get_attachment_url” to remove the file path inserted by the remote wp-admin.

    Thanks @sqlwiz.

    @fredericktownes: WLW issue resolved. It automatically recognises the CDN.

    My current problem now is that whenever I deactivate W3 TOTAL CACHE. I get 404 errors on ALL my blog posts. What could be wrong?

    There might be directives from disk enhanced mode in the .htaccess file?

    The code below appears in my htaccess

    # BEGIN W3 Total Cache
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_URI} !\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register).php [OR]
        RewriteCond %{REQUEST_URI} wp-comments-popup\.php|wp-links-opml\.php|wp-locations\.php [NC]
        RewriteCond %{REQUEST_METHOD} !=POST
        RewriteCond %{QUERY_STRING} =""
        RewriteCond %{HTTP_COOKIE} !comment_author|wp-postpass|wordpress_\[a-f0-9\]\+|wordpress_logged_in [NC]
        RewriteCond %{HTTP_USER_AGENT} !bot|ia_archive|slurp|crawl|spider|2\.0\ MMP|240x320|ASUS|AU-MIC|Alcatel|Amoi|Android|Audiovox|AvantGo|BenQ|Bird|BlackBerry|Blazer|CDM|Cellphone|DDIPOCKET|Danger|DoCoMo|Elaine/3\.0|Ericsson|EudoraWeb|Fly|HP\.iPAQ|Haier|Huawei|IEMobile|J-PHONE|KDDI|KONKA|KWC|KYOCERA/WX310K|LG|LG/U990|Lenovo|MIDP-2\.0|MMEF20|MOT-V|MobilePhone|Motorola|NEWGEN|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Novarra|O2|Opera\ Mini|Opera\.Mobi|PANTECH|PDXGW|PG|PPC|PT|Palm|Panasonic|Philips|Playstation\ Portable|ProxiNet|Proxinet|Qtek|SCH|SEC|SGH|SHARP-TQ-GX10|SIE|SPH|Sagem|Samsung|Sanyo|Sendo|Sharp|Small|Smartphone|SoftBank|SonyEricsson|Symbian|Symbian\ OS|SymbianOS|TS21i-10|Toshiba|Treo|UP\.Browser|UP\.Link|UTS|Vertu|WILLCOME|WinWAP|Windows\ CE|Windows\.CE|Xda|ZTE|dopod|hiptop|htc|i-mobile|iPhone|iPod|nokia|portalmmm|vodafone [NC]
        RewriteCond /home/mogbn/public_html/blog/wp-content/w3tc/pgcache/%{HTTP_HOST}/$1/index.html%{ENV:APPEND_EXT} -f
        RewriteRule (.*) wp-content/w3tc/pgcache/%{HTTP_HOST}/$1/index.html%{ENV:APPEND_EXT} [L]
    # END W3 Total Cache

    Will deleting it stop the 404 errors. I just want to confirm should in case at some point in time I need to uninstall the plugin.

    If plugin disabled, those rules should be removed otherwise you will have unexpected behavior.

    Thanks a million 😉

    You’re welcome.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Plugin: W3 Total Cache] image gallery not working with cdn enabled’ is closed to new replies.