Remove images from PMs that have been inactive for >1 year


(Anton) #1

What would be the correct way to remove all images from all PM topics with no activity for e.g. 1+ years. I’d like to do so as a means to reduce storage occupied by uploads.

By making so in a “correct way” I mean in such a way that the images will be then automatically removed / cleaned up as not used ones (orphan ones).


(Régis Hanol) #2

I would write a plugin with a background job that runs daily and replace all images with some text (eg “[image removed after 1 year]”) in the raw version of posts in PM older than 365 days. Discourse will do the rest.


(Anton) #3

Should be achievable by a sql query? I could run it manually once a year :slight_smile: What field should I update to trigger re-cooking a message in which the “raw” content gets changed


(Jay Pfaffman) #4

I think your solution might involve this: Replace a string in all posts