Skip to content

Instantly share code, notes, and snippets.

@arpitr
Created December 31, 2020 05:16
Show Gist options
  • Save arpitr/f61623f35527d8e8f3712d9e73a358ae to your computer and use it in GitHub Desktop.
Save arpitr/f61623f35527d8e8f3712d9e73a358ae to your computer and use it in GitHub Desktop.
Delete Media Entities of certain type
// Change the bundle that needs to be deleted.
drush php-eval '$ids = \Drupal::entityQuery("media")->condition("bundle", "image")->execute();$storageHandler = \Drupal::entityTypeManager()->getStorage('media');$entities = $storageHandler->loadMultiple($ids);foreach ($entities as $entity) {$entity->delete();}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment