The issue revolves around the PullHotlinkedImages feature in Discourse not re-downloading or replacing images after a post is edited, particularly when edits are made via the API or system actions (e.g., category changes triggered by WP-Discourse). Arkshine reported that while images are correctly replaced during initial topic creation, subsequent edits revert to hotlinked images, and PullHotlinkedImages fails to act — even after manually triggering it or resetting baked_version. david identified the root cause: the system only replaces URLs during the first image download, not on subsequent edits. He created a failing test case to replicate this. After a fix was implemented in commit cb12a72, Arkshine confirmed that manual edits now trigger image replacement successfully. A new spec was added to prevent future regressions. The fix addresses the core logic flaw, ensuring PullHotlinkedImages behaves consistently across all post edits, regardless of origin.
Actually, the issue with downloading images on edited topics with system doesn’t seems to be fully solved. Sorry for not noticing it earlier. For example this one or this one.
As reminder, in our case, it’s an automatic category change (using API).
My client still have topics where PullHotlinkedImages does nothing no matter what:
When I say “new topic”, I mean directly on Discourse, not via API.
Originally, it’s a topic created from WP-Discourse; so should be this code:
For example, if you look at the first edit of the topic linked above, You see well the system replacing the images. So, WP-Discourse is likely not an issue.
Perfect, thanks for the detailed summary! I think the problem is here:
I managed to produce a failing test case for this. It seems we only do the URL replacement when the image is first downloaded. If we have already downloaded the image once, it won’t be replaced again.
This is a failing test which demonstrates the issue
I just fastly edited/saved few topics manually which was edited by system and it seems that PullHotlinkedImages is working now. Will try the command line later, but no doubt it will working fine.