Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback. 

Per Nergård (MVP)
Jan 21, 2025
  316
(0 votes)

Find and delete non used media and blocks

On my new quest to play around with Blazor and MudBlazor I'm going back memory lane and porting some previously plugins. So this time up is my plugin for finding non used images in the global assets folder and you can read the old blog post from 2017 over here.

I decided I wanted to update it a bit so it could look for blocks as well. It's not that much to tell about it but you can choose if you want to look for media and / or blocks and look for orphans and then optionally delete selected or all.

You can grab the code over at my Gist.

I have in my tests used the component in a page type I have setup for Blazor testing but if you want to have it as a plugin have a look at Ove Lartelius excellent post about how to run you components in different areas of the Optimizely UI here.

And it looks like this

Jan 21, 2025

Comments

Shamrez Iqbal
Shamrez Iqbal Jan 21, 2025 11:25 AM

Is the Gist link wrong?

Per Nergård (MVP)
Per Nergård (MVP) Jan 21, 2025 12:13 PM

Yes it was. I've fixed it now.

Mike Malloy
Mike Malloy Jan 23, 2025 09:35 PM

I had a question on the Delete. If I wanted to instead Move the content to a specific folder for review, I was trying the following with IContentChangeManager:

_contentChangeManager.Move(content, destination, false);

I get a ContentNotFoundException if the block references a Commerce Catalog that doesn't exist anymore. Is that just how it works? The referenced content must exist in order for it to be moved?

Per Nergård (MVP)
Per Nergård (MVP) Jan 24, 2025 08:31 AM

Hi

I built it for CMS so I'm not sure how it works for commerce. Can't you just change the contents parentlink to the new folder and save the content using the IContentRepository.Save(......)?

Please login to comment.
Latest blogs
How to: set access right to folders

Today I stumped upon this question Solution for Handling File Upload Permissions in Episerver CMS 12, and there is a simple solution for that Using...

Quan Mai | Feb 7, 2025 | Syndicated blog

Poking around in the new Visual Builder and the SaaS CMS

Early findings from using a SaaS CMS instance and the new Visual Builder grids.

Johan Kronberg | Feb 7, 2025 | Syndicated blog

Be careful with your (order) notes

This happened a quite ago but only now I have had time to write about it. Once upon a time, I was asked to look into a customer database (in a big...

Quan Mai | Feb 5, 2025 | Syndicated blog

Imagevault download picker

This open source extension enables you to download images as ImageData with ContentReference from the ImageVault picker. It serves as an alternativ...

Luc Gosso (MVP) | Feb 4, 2025 | Syndicated blog