• Resolved Chad Reitsma

    (@chadreitsma)


    Hey guys,

    I have an AJAX function which is returning content but W3 is not applying my CDN CNAME to URLs. I assume I need to pass this through another filter?

    Does anyone know a filter that can take supplied content (HTML) and replace the site’s url with the CDN’s CNAME. I wrote my own, but would like to use native filters if they exist.

    Example:
    $content = https://mysite.com/wp-content/uploads/2021/image.jpg
    $content = apply_filters(‘w3tc_cdn_urls’, $content);

    Output of $content would then be filtered to:
    $content = https://mycdn.cname.com/wp-content/uploads/2021/image.jpg

    I tried using w3tc_processed_content, but I don’t think I instantiated that correctly, could I simply use New W3TC\Generic_Plugin, then call ob_callback( $buffer )?

    Cheers,
    C.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @chadreitsma

    Thank you for your question and I am happy to assist you with this.
    Can you please share the website URL?
    Which CDN are you using and is there any specific type of files?
    IF the CDN URL rewrite fails, it means that the URLs got to the page via some non-regular way. The plugin does the best but may not know code business logic and there are still cases when code will “win” and put the original URL on-page.
    For example from javascript code when URL is concatenated or coming from ajax response when URLs dont pass filter.
    Thanks!

    Thread Starter Chad Reitsma

    (@chadreitsma)

    Hi Marko,
    Yes – I am using AJAX – so W3 is not catching the URLs. Is there a filter I can use to process that content before outputting it to the browser?

    We are using Amazon Cloudfront.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @chadreitsma

    Thank you for your patience.
    At the moment, there is no filter for this.
    I’ve created a Github issue on your behalf in our GitHub repository.
    Please make sure to track the progress of the issue regularly and feel free to comment on it and add any additional information if you see it convenient.
    Thanks!

    Thread Starter Chad Reitsma

    (@chadreitsma)

    Sounds good. Thanks Marko! ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Filter to replace URLs with CDN url?’ is closed to new replies.