A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Per Nergård (MVP)
Jan 21, 2025
  1313
(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
Building simple Opal tools for product search and content creation

Optimizely Opal tools make it easy for AI agents to call your APIs – in this post we’ll build a small ASP.NET host that exposes two of them: one fo...

Pär Wissmark | Dec 13, 2025 |

CMS Audiences - check all usage

Sometimes you want to check if an Audience from your CMS (former Visitor Group) has been used by which page(and which version of that page) Then yo...

Tuan Anh Hoang | Dec 12, 2025

Data Imports in Optimizely: Part 2 - Query data efficiently

One of the more time consuming parts of an import is looking up data to update. Naively, it is possible to use the PageCriteriaQueryService to quer...

Matt FitzGerald-Chamberlain | Dec 11, 2025 |

Beginner's Guide for Optimizely Backend Developers

Developing with Optimizely (formerly Episerver) requires more than just technical know‑how. It’s about respecting the editor’s perspective, ensurin...

MilosR | Dec 10, 2025