update image URLs when querying post_content data from database
-
We are attempting to use a plugin to share content between sites in a multisite. We are testing https://rudrastyh.com/plugins/simple-multisite-crossposting to do so. The plugin works well, except it does not work with WP Offload – which is an absolute must for us. Here is the issue:
When you add a post to 1 site (primary), you can select from the other network sites (secondary) to push the post to. If you add images to the body of the post on the primary, the WP Offload plugin does it’s thing and offloads the image (we use AWS S3) and then rewrites the URL for the body of the post. As you know – the URL remains as a local URL if you look in the post_content field in the database, and the WP Offload plugin rewrites the URL when the post is displayed on the website and also when you edit the post in the admin.
When the post information gets copied to a secondary site, the post_content field contains the local URL. However, since there is no reference to this image being moved to S3 in the wp_as3cf_items table of the secondary site – WP Offload does NOT rewrite the URL using the S3 location when the post is displayed or edited through the secondary site.
We do NOT retain the local copy after it is moved to S3, so the local URL that the secondary site is referencing is no longer valid and shows a broken image.
The question I have is – is there a function that can be ran on the post_content field when doing a DB query from the primary site that will update the URLs in the post_content? If so – this could be used by the crossposting plugin (either by us editing the plugin or reaching out to the author to include it) when copying information from primary’s wp_posts table to the secondary wp_posts table so that the URLs are already converted to the appropriate S3 location. With the URLs already converted – there would be no more issue with the images due to the secondary site not have a reference in the wp_as3cf_items table.
Thank you to anyone who can offer any assistance with this!
Jim
The topic ‘update image URLs when querying post_content data from database’ is closed to new replies.