Per Nergård (MVP)
Jan 21, 2025
  1698
(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
Meet the latest OMVPs - H1 2026 Cohort

Meet the Latest Cohort of Optimizely Most Valuable Professionals (OMVPs) Every year, the Optimizely Most Valuable Professional (OMVP) program...

Satata Satez | Mar 13, 2026

Optimizely Commerce vs Composable Commerce: What Should You Do with CMS 13?

As organizations modernize their digital experience platforms, a common architectural question emerges: Should we continue using Optimizely Commerc...

Aniket | Mar 12, 2026

Missing Properties tool for Optimizely CMS

If you have been working with Optimizely CMS for a while you have probably accumulated some technical debt in your property definitions. When you...

Per Nergård (MVP) | Mar 10, 2026

AI Generated Optimizely Developer Newsletter

Updates in the Optimizely ecosystem are everywhere: blog posts, forums, release notes, NuGet packages, and documentation changes. This newsletter...

Allan Thraen | Mar 10, 2026 |