• Resolved Alex Furr

    (@alexfurr)


    Hi,
    Great plugin – thank you!
    We have come across an edge case was hoping you could advise.
    We are using ‘switch_to_blog()’ to get content from a post on another blog on a multisite network.

    We do this using the following code

    $question = apply_filters('the_content', get_post_field('post_content', $post_id));

    Instead of an s3 bucket URL, it’s giving the original ‘local’internal url.

    Is there any filter we can apply to get this image ref correct, or are we ‘doing it wrong’?

    Thanks in advance!
    BW,
    Alex

    • This topic was modified 3 years, 3 months ago by Alex Furr.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Alex Furr

    (@alexfurr)

    Checking the code on this page:
    https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront/blob/master/classes/as3cf-filter.php

    It looks I just need to run the ‘process_content()’ method and pass my content.

    Is there any way of doing that using the apply_filters method?

    Thread Starter Alex Furr

    (@alexfurr)

    Forget the apply_filters stuff!
    I just need a way of calling the process_content or the filter_post method in your plugin on a generic piece of content. Does that exist?

    Plugin Author Delicious Brains

    (@deliciousbrains)

    WP Offload Media hooks into the the_content and the_post filters along with many others to make sure that when a post and its content is accessed with standard functions the local URLs are rewritten to bucket/CDN URLs if appropriate.

    I’m surprised that get_post_field() doesn’t do the do for you, maybe there’s other filters hanging off the_post or the_content that are causing issues?

    Normally, switching to blog and retrieving a post with filtered content should be fine.

    However, if needs must, there’s a way of asking WP Offload Media to filter a lump of custom content…

    https://deliciousbrains.com/wp-offload-media/doc/filtering-urls-in-custom-content/

    If that doesn’t help, might be worth checking that the content to be filtered is using the expected subsite domain name in its URLs. If not, you may just need to tell WP Offload Media that there’s an additional domain name that can be used for the subsite.

    https://deliciousbrains.com/wp-offload-media/doc/filtering-urls-for-multiple-domains/

    -IJ

    Thread Starter Alex Furr

    (@alexfurr)

    H IJ,

    Thanks so much for your reply. That looks like the exact filter I was looking for.

    Unfortunately it still doesn’t work, but we’ve got a workaround for now, although would be good to get to the bottom of it at some point.
    Happy to send you any diagnosis logs / access etc as we use the switch_to_blog method a fair bit.

    We don’t have domain forwarding / subdomains so your other link doesn’t look it’s applicable.
    Best wishes,
    Alex

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Embedded image showing ‘old’ url source’ is closed to new replies.