# Uploads not getting orphaned and purged

**URL:** https://meta.discourse.org/t/uploads-not-getting-orphaned-and-purged/259036
**Category:** Support
**Created:** [March 22, 2023, 1:47pm UTC](https://meta.discourse.org/t/uploads-not-getting-orphaned-and-purged/259036 "2023-03-22T13:47:52Z")
**Posts on this page:** 1
**Showing post:** 10

<div class="post-metadata">

### Author: ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)
#### Post date: [April 19, 2024, 3:35am UTC](https://meta.discourse.org/t/uploads-not-getting-orphaned-and-purged/259036/10 "2024-04-19T03:35:46Z")

</div>

Another relevant topic, I posted on there as I wasn’t aware of this topic.

> [@Auto purge uploads from old deleted posts](https://meta.discourse.org/t/auto-purge-uploads-from-old-deleted-posts/51306):
>
> Discourse already automatically removes orphan unreferenced uploads. Why not expand this functionality and erase uploads from deleted posts? Only staff members are able to see deleted posts and that is very useful. But is it really necessary to keep all the files indefinitely? As administrator I really don`t care about 2 years old deleted pictures. Some of which may even be right out against site guidelines. It would be nice if Discourse would automatically delete these kind old files and place…

I believe the only way to really delete an image in an automatic way is to manually edit it out of the post before deleting it. But I’m not entirely sure that works either. I’m using identical settings to you regarding purging (but use S3 compatible storage) and I can also confirm that images never get purged if the only post containing that image (several posts can contain the same image, presumably avatars and user banners also) is deleted.

I use this solution to search to see if an image is used in additional posts, which was provided by @RGJ

> [@DMCA - Remove Individual Image Best Practices](https://meta.discourse.org/t/dmca-remove-individual-image-best-practices/156817/4):
>
> Just open a rails console and enter the following, replacing the large string with the large string in the image URL. If this is an optimized image then remove everything starting from the first underscore (\_). Upload.find\_by\_sha1('c35ab963fb22f8612697923ebc98d341693cfa1d').posts.each do |p| puts p.url end This will give you the URL(s) to one or more posts that contain the image. This code will give you the paths to the image and all associated optimized images, assuming local storage. …

Would really be great if this could be done automatically. Particularly due to Discourse handling images in a smart way, with preventing creating duplicates files if many posts use the same image. The flip side is it’s very tedious to remove individual images that have been used a lot.

I’ve had someone spam content that needed urgent removal via several accounts before and it was very stressful trying to deal with it and ensure it was entirely removed (all original files, optimised files, cdn cache, posts, avatars, user banners etc.).

I made this feature suggestion, as it would be very helpful imo. If this was implemented, as well as automatically purging content contained in deleted posts, I think all cases would be covered and could be handled without SSH access.

> [@Feature suggestion: Image removal/purge via web dashboard](https://meta.discourse.org/t/feature-suggestion-image-removal-purge-via-web-dashboard/247011):
>
> So the suggestion is: Ability to input an image url in the discourse moderator panel (any variation, original, optimised etc.) for removal. Then remove the image from all cases it’s being used in (posts, profile images like avatar, background etc.) and purge it (all variations) from the image storage (local or S3). Potentially could ban the hash of the image to prevent it being uploaded again in the future also. Discourse handles images in a really nice way, so that identical images being used…

---

_[View the full topic](https://meta.discourse.org/t/uploads-not-getting-orphaned-and-purged/259036)._
