WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
[resolved] Change image paths in CSS to CDN (8 posts)

  1. AmirHelzer
    Member
    Posted 3 years ago #

    Our CSS includes many references to images. For example:


    background: url('/wp-content/plugins/fancybox-for-wordpress/css/img/fancy_progress.png');

    Can W3TC convert these URLs to URLs in the CDN?

    If this isn't done in the plugin, I'll be more than happy to write it and submit as a patch.

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

  2. kfawcett
    Member
    Posted 3 years ago #

    Yes, it does that automatically.

  3. ichilton
    Member
    Posted 3 years ago #

    Hi,

    I had the same problem and it's something I commented on in my post here:

    http://www.ichilton.co.uk/blog/wordpress/wordpress-caching-plugins-and-observations-with-w3-total-cache-184.html

    I believe it's because the url starts with / so it serves it from the same domain as the css (which if you are using the automatic minify mode will be the domain of your site rather than the CDN).

    If you do create a patch, i'd be interested to see it as I was looking to do the same thing but have not had chance yet.

    Thanks,

    Ian

  4. AmirHelzer
    Member
    Posted 3 years ago #

    Thanks Ian,

    I'll check with relative URLs and see if it works. If it does, it's going to be a big speed improvement for loading the entire page.

  5. ichilton
    Member
    Posted 3 years ago #

    Cool - let me know how you get on as i'd like to get the same working.

    Thanks,

    Ian

  6. AmirHelzer
    Member
    Posted 3 years ago #

    Actually, kfawcett, can you point me to the code that does the URL replacements for CDN and the code that creates the minified CSS files?

    I'd be happy to debug it, see why it's not working for us and provide a patch. It would help if I know what I'm looking for.

  7. Frederick Townes
    Member
    Plugin Author

    Posted 3 years ago #

    Was there any remedy?

  8. AmirHelzer
    Member
    Posted 3 years ago #

    Once we got the CSS files themselves served from the CDN, the linked images (from the CSS) started coming from the CDN as well.

    For this to happen, the CSS must reference these images with relative paths (paths that don't have the domain name). This way, the images would come from whatever domain the CSS file is in.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic