Take the community feedback survey now.

Per Nergård (MVP)
Jan 21, 2025
  1007
(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
Opal Core Concepts

Before you dive into the code, it's crucial to understand the foundational ideas that make Opal tick. Core concepts are consistent across all its...

K Khan | Sep 13, 2025

Optimizely Opal : Reimagining A Utility Sector Use Case

  Introduction Customer engagement through timely and personalized push notifications plays a crucial role in todays Digital First landscape. In th...

Ratish | Sep 12, 2025 |

A day in the life of an Optimizely OMVP - AEO & GEO: The Future of Digital Visibility with Optimizely

The way people discover content online is undergoing a seismic shift. Traditional SEO is no longer enough. With AI-powered tools like ChatGPT,...

Graham Carr | Sep 12, 2025

Building Optimizely OCP Apps Faster with AI and Coding Assistants

Developing Optimizely Connect Platform (OCP) apps can be a rewarding but complex process—especially when integrating with external APIs. Over the...

Pawel Zieba | Sep 11, 2025