• Resolved jamiolee

    (@jamiolee)


    I noticed that any remote images embedded inside the post content would automatically have their URL’s rewritten to local ones upon updating the post. I have this plugin configured to automatically delete the local copies of all images, so none of them would show when viewing the post on the front-end.

    I have “Rewrite Media URLs” enabled so they should be served from Amazon CloudFront. However, upon digging through your code I discovered that if I disable the filter:

    add_filter( ‘content_save_pre’, array( $this, ‘filter_post’ ) );

    in the file:

    amazon-s3-and-cloudfront/classes/filters/as3cf-s3-to-local.php

    this resolves my issue.

    My question is: why does this filter exist in your plugin? It quite literally defeats the purpose of this plugin.

    • This topic was modified 2 years, 6 months ago by jamiolee.
    • This topic was modified 2 years, 6 months ago by jamiolee.
    • This topic was modified 2 years, 6 months ago by jamiolee.
    • This topic was modified 2 years, 6 months ago by jamiolee.
    • This topic was modified 2 years, 6 months ago by jamiolee.
    • This topic was modified 2 years, 6 months ago by jamiolee.
    • This topic was modified 2 years, 6 months ago by jamiolee.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Delicious Brains

    (@deliciousbrains)

    My question is: why does this filter exist in your plugin?

    That filter ensures that when you edit a post and include offloaded media URLs in the content, then those URLs get rewritten back to local URLs before the content is saved to the database.

    This ensures maximum compatibility with WordPress that expects local URLs in the database content.

    It also means that when the post is displayed by WP and WP Offload Media dynamically rewrites those local URLs back to remote URLs, it can do so and instantly pick up changes to the CDN custom domain etc. Without the local to remote URL rewriting feature WPOM would need to trawl the database content for all remote URLs using the old CDN domain (or bucket URL) and update them should settings be changed.

    That is how WPOM worked before version 1.2:

    https://deliciousbrains.com/wp-offload-s3-1-2-released/#old-implementation

    It was not great, especially for sites with large collections of either media or posts.

    There’s info about the URL rewriting in our Developer’s Guide:

    https://deliciousbrains.com/wp-offload-media/doc/developer-guide/#rewrite-urls

    It sounds like URL rewriting isn’t working for you.

    Please can we see Diagnostic Info from WP Offload Media’s “Support” tab, and debug.log output captured during a page display that fails to rewrite URLs?

    https://deliciousbrains.com/why-use-wp-debug-log-wordpress-development/

    -IJ

    Thread Starter jamiolee

    (@jamiolee)

    Thank you for the very informative response. That gave me a good starting point for my investigation into the cause of why the URLs were not getting written back to their remote counterparts.

    It turns out a previous developer on my project was retrieving the post content data directly from the database instead of using the WP global post or post retrieving functions. I have corrected this and can confirm that WP Offload Media Lite is now correctly re-writing the URLs to the CDN location on page content load.

    Thanks again for your help.

    Plugin Author Delicious Brains

    (@deliciousbrains)

    Excellent, glad I could help.

    -IJ

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post Content Filters Image URL’ is closed to new replies.