Take the community feedback survey now.

Per Nergård (MVP)
Jan 21, 2025
  1150
(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
Optimizely CMS Mixed Auth - Okta + ASP.NET Identity

Configuring mixed authentication and authorization in Optimizely CMS using Okta and ASP.NET Identity.

Damian Smutek | Oct 27, 2025 |

Optimizely: Multi-Step Form Creation Through Submission

I have been exploring Optimizely Forms recently and created a multi-step Customer Support Request Form with File Upload Functionality.  Let’s get...

Madhu | Oct 25, 2025 |

How to Add Multiple Authentication Providers to an Optimizely CMS 12 Site (Entra ID, Google, Facebook, and Local Identity)

Modern websites often need to let users sign in with their corporate account (Entra ID), their social identity (Google, Facebook), or a simple...

Francisco Quintanilla | Oct 22, 2025 |

Connecting the Dots Between Research and Specification to Implementation using NotebookLM

Overview As part of my day to day role as a solution architect I overlap with many clients, partners, solutions and technologies. I am often...

Scott Reed | Oct 22, 2025