Request to delay post from wordpress

I am using the WP Offload Media plugin to send my images to s3 on wordpress, but the images take a minute to move over to s3 when the post is published. The problem is the discourse plugin is immediate so the post gets sent over to discourse with the links to images that are locally hosted, and shortly thereafter the offload plugin sends them to s3, and now the original links are broken in the discourse post. If there was a simple setting to delay the discourse post by say 5 minutes it would resolve this issue.

Doesn’t that plugin include the option to move to S3 from the media library? If so you can get your files into S3 prior to publishing.

Edit: Yes, looks like it does, you can select the images prior to publishing and offload them:

It makes much more sense for you to use existing functionality that achieves the same result, than ask for new features to be developed.


Thanks Stephen, I reached out to the developers and received this response

The images are sent to S3 as soon as they are uploaded to the Media Library, whether that’s directly with “Add New” or via “Add Media” when editing a post. So while drafting a post any media should be showing S3 URLs.

If that is correct, but when you publish your post it still sends content with local URLs to Discourse, then it’s likely that whatever plugin you’re using for that is not properly processing “the_content” via WP’s filters. The following guide may be of help.
Filtering URLs in Custom Content

Can anyone confirm that the discourse plugin is using the_content?

1 Like

Here’s another example of a post I just published, I even tried using the update post feature and it did not change. So it actually doesn’t seem to be related to the plugin or delay at all. For some reason, the discourse plugin is taking the local file url instead of cdn url which is actually in the source code.

If you view the source on this page:
The first image in post is this:

Wordpress Source

<img class="alignnone size-full wp-image-1248" src="" alt="GlowingGroveWEB" width="2133" height="1200" srcset=" 2133w, 300w, 768w, 1024w, 600w" sizes="(max-width: 2133px) 100vw, 2133px" />

And the html that was published to discourse was this:

<img class="alignnone size-full wp-image-1248" src="" alt="GlowingGroveWEB" width="2133" height="1200" />
 <h4>Focus On A Single Tree</h4>


Have you inspected the database to check if your S3 plugin is updating post_content or post_content_filtered?

No, it isn’t. I’ll look into it some more as to whether or not it should be applying that filter. The main problem I see with it is that if shortcodes get parsed there can be a lot of display issues on Discourse.

For the moment, you can apply the filter yourself, or apply the as3cf_filter_post_local_to_s3 filter. You can do this by hooking into the wp_discourse_excerpt filter that the plugin applies to the post content that’s published from WordPress to Discourse. Only try this if you have someway of accessing the backend of your site in case something goes wrong when adding the code. Try one or the other of these code snippets to your theme’s functions.php file.

add_filter( 'wp_discourse_excerpt', 'wpdc_custom_excerpt' );
function wpdc_custom_excerpt( $content ) {
    return apply_filters( 'as3cf_filter_post_local_to_s3', $content );
add_filter( 'wp_discourse_excerpt', 'wpdc_custom_excerpt' );
function wpdc_custom_excerpt( $content ) {

    return apply_filters( 'the_content', $content );

With version 1.7.9 of the WP Discourse plugin, if the full post content is published to Discourse, the the_content filter is applied to the content before it is published. This is being done to remove the markup that WordPress adds to posts that are published with the Block Editor.

Let me know if this causes any issues.


Looks good, only bit of weirdness is the image caption goes to the right of the image rather than below it now.

I can reproduce that If the image doesn’t take up the full width of the post.

Edit: if images on your forum are being lightboxed, a possible solution to this would be to add something like this to your Discourse theme’s CSS:

.lightbox-wrapper {
    display: block;

Discourse is displaying .lightbox-wrapper as inline-block. This is why the caption text can appear to the right of the image. I’m not sure if there will be any issues with using display: block instead. I’ll test it out and see.


Sorry for the delay, I just tried this and it does not work, unfortunately.

Also, I just published a new post which has centered square images, on discourse it is stretching the images to fill the container even though the html looks correct.

Original post: Finding Your Muse in Nature Photography - NPN

I have the articles section on discourse locked down to members, so here is a screenshot and a portion of the html:

<small>Originally published at:
<div class="wp-block-image"><figure class="aligncenter is-resized"><img src="" alt="Music From Dark Spaces IX" class="wp-image-3589" width="512" height="512" srcset=" 1024w, 150w, 300w, 768w, 600w, 100w, 1500w" sizes="(max-width: 512px) 100vw, 512px" /></figure></div>