SaaS CMS has officially launched! Learn more now.

Per Nergård
Sep 5, 2017
  4804
(6 votes)

Plugin for deleting unreferenced media

Sometimes you need to synch a dev-environment with production database and media and the blob-storage is huge with likely a lot of unreferenced media or perphaps want to clean up a test-environment.

To help in those two scenarios I threw togheter a small plugin that lets you delete all or just selected unreferenced media. Really nothing to say about the code than it can be found over at my Gist.

It looks like this:

Image cleaner.jpg

Sep 05, 2017

Comments

valdis
valdis Sep 6, 2017 08:44 AM

where you were couple weeks ago? when we had ~ 1TB of unreferenced media ?? :) great plugin

Sep 6, 2017 09:13 AM

Valdis: Thanks. Actually did this before the vacations but haven't got around blogging for quite a while. Been thinking about doing a scheduled job version for a more hardcore approach to keeping the assets folder clean :)

Luc Gosso (MVP)
Luc Gosso (MVP) Sep 6, 2017 01:55 PM

The wheel is already invented =)

https://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2017/6/quotremove-abandoned-blobsquot-scheduled-job-doesn39t-remove-all-abandoned-blobs/

Removed about 12% on production server, take backup in case.

Sep 6, 2017 03:06 PM

Gosso: I googled before I made the plugin but not good enough. But my version has cherry picking of files. :)

Luc Gosso (MVP)
Luc Gosso (MVP) Sep 6, 2017 03:56 PM

Also check out the mega super awesome amazing DownloadIfMissingFileBlogProvider for dev and staging environment.

with that addon you can

  • ... delete all blobs - and it takes care of downloading the images/documents you need
  • ... use diskspace to other things... It only downloads the blobs you're using
  • ... go home earlier, since you'll never ever need to download the blob-directory anymore.

Try it =)

Sep 6, 2017 04:16 PM

I agree that your DownloadIfMissingFileBlogProvider is the best thing since slice bread. :)

valdis
valdis Sep 7, 2017 05:59 PM

I guys will leave you there :D

Johan Book
Johan Book Feb 17, 2018 10:31 AM

I just wrote a quick script to remove blobs that have no entry in CMS, then I found this post :D

To Per's defence, his version does indeed go one extra step by checking what's actually referenced, and not only what exists in CMS. The DownloadIfMissing plugin looks awesome, but if you can't use it for some reason you'll need to do a combination of both approaches to slim it to the maxx. Thanks Per!

Feb 26, 2018 11:44 PM

Glad you found it usefull.

Please login to comment.
Latest blogs
Optimizely release SaaS CMS

Discover the future of content management with Optimizely SaaS CMS. Enjoy seamless updates, reduced costs, and enhanced flexibility for developers...

Andy Blyth | Jul 17, 2024 | Syndicated blog

A day in the life of an Optimizely Developer - London Meetup 2024

Hello and welcome to another instalment of A Day In The Life Of An Optimizely Developer. Last night (11th July 2024) I was excited to have attended...

Graham Carr | Jul 16, 2024

Creating Custom Actors for Optimizely Forms

Optimizely Forms is a powerful tool for creating web forms for various purposes such as registrations, job applications, surveys, etc. By default,...

Nahid | Jul 16, 2024

Optimizely SaaS CMS Concepts and Terminologies

Whether you're a new user of Optimizely CMS or a veteran who have been through the evolution of it, the SaaS CMS is bringing some new concepts and...

Patrick Lam | Jul 15, 2024

How to have a link plugin with extra link id attribute in TinyMce

Introduce Optimizely CMS Editing is using TinyMce for editing rich-text content. We need to use this control a lot in CMS site for kind of WYSWYG...

Binh Nguyen Thi | Jul 13, 2024

Create your first demo site with Optimizely SaaS/Visual Builder

Hello everyone, We are very excited about the launch of our SaaS CMS and the new Visual Builder that comes with it. Since it is the first time you'...

Patrick Lam | Jul 11, 2024