Strapi plugin logo for Media Deletion Check

Media Deletion Check

Check if a media is used in a content before deletion

thumbnail for Media Deletion Check

strapi-media-deletion-middleware

Check if a media is used in any content before deleting it.

Works with strapi 4 and 5

Install

npm i @openstudio/strapi-media-deletion-middleware
# Or
yarn add @openstudio/strapi-media-deletion-middleware

Configuration

Basic

Add in config/middleware.ts

1module.exports = ({ env }) => [
2  // ...
3  {
4    resolve: '@openstudio/strapi-media-deletion-middleware',
5  },
6  // ...
7];

Custom

To modify some default values add a config object with the config key you want to edit.

1module.exports = ({ env }) => [
2  // ...
3  {
4    resolve: '@openstudio/strapi-media-deletion-middleware',
5    config: {
6      strapiMajor: 4,
7      blackList: [{ relatedType: 'api::article.article', field: 'cover' }],
8      whiteList: [
9        { relatedType: 'api::article.article', field: 'optionalField' },
10      ],
11    },
12  },
13  // ...
14];

Config parameters

keydescriptiondefault
strapiMajorStrapi Major version in this project
possible values : 4 or 5
5
blackListSpecify a list of elements whose medias CAN'T be deleted, an empty list means everything is in the black list[]
whiteListSpecify a list of elements whose medias CAN be deleted, for instance if a media is in an optional field you might allow to delete it[]

Install now

npm install @openstudio/strapi-media-deletion-middleware

STATS

1 GitHub star16 weekly downloads

Last updated

71 days ago

Strapi Version

Unavailable

Author

github profile image for OpenStudio
OpenStudio

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.