Delete the associated media with the given id.
You may also pass a media object.

@param int|\Spatie\MediaLibrary\Models\Media $mediaId

@throws \Spatie\MediaLibrary\Exceptions\MediaCannotBeDeleted
507665
public function deleteMedia($mediaId)
    {
        if ($mediaId instanceof Media) {
            $mediaId = $mediaId->id;
        }

        $media = $this->media->find($mediaId);

        if (! $media) {
            throw MediaCannotBeDeleted::doesNotBelongToModel($mediaId, $this);
        }

        $media->delete();
    }
241915
public function delete($mediaId)
    {
        return $this->http->get(self::API_FOREVER_DELETE, array('media_id' => $mediaId, 'agentid' => $this->agentId));
    }
850849
public void delete(String mediaId) {
        String url = WxEndpoint.get("url.material.delete");
        String body = String.format("{\"media_id\":\"%s\"}", mediaId);
        logger.debug("material delete: {}", body);
        wxClient.post(url, body);
    }
88110
public static function remove($id)
    {
        $asset = self::find($id)->first();
        $media = $asset->media;

        foreach ($media as $file) {
            if (! is_file(public_path($file->getUrl())) || ! is_writable(public_path($file->getUrl()))) {
                return;
            }
        }

        $asset->delete();
    }
1241688
public function actionDelete($id)
    {
        $model = $this->findModel($id);
        if ($model->deleteWithRelated()) {
            delete_media_path($model->path);
            set_flash_success_delete_content();
        } else {
            set_flash_error_delete_content();
        }

        return $this->goBack(request()->referrer);
    }
824675
public function delete($sOXID = null)
    {
        $sFilePath = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('sShopDir') . "/out/media/" .
                     basename($this->oxmediaurls__oxurl->value);

        if ($this->oxmediaurls__oxisuploaded->value) {
            if (file_exists($sFilePath)) {
                unlink($sFilePath);
            }
        }

        return parent::delete($sOXID);
    }
1206088
public function remove($parentId, $id)
    {
        $resource = $this->createPartialResourceUrlForView($parentId, $id);
        $this->client->delete($resource);
    }
317580
public function removeMedias(array $mediaIds)
    {
        $mediaMongoIds = array();
        foreach ($mediaIds as $mediaId) {
            $mediaMongoIds[] = new \MongoId($mediaId);
        }

        $qb = $this->createQueryBuilder();
        $qb->remove()
            ->field('id')->in($mediaMongoIds)
            ->getQuery()
            ->execute();
    }
220443
protected function handle_featured_media( $featured_media, $post_id ) {

		$featured_media = (int) $featured_media;
		if ( $featured_media ) {
			$result = set_post_thumbnail( $post_id, $featured_media );
			if ( $result ) {
				return true;
			} else {
				return new WP_Error( 'rest_invalid_featured_media', __( 'Invalid featured media id.' ), array( 'status' => 400 ) );
			}
		} else {
			return delete_post_thumbnail( $post_id );
		}

	}
842354
public function deleteFileAndChunksById($id)
    {
        $this->filesCollection->deleteOne(['_id' => $id]);
        $this->chunksCollection->deleteMany(['files_id' => $id]);
    }
119203
public function removeMedia(Media $media)
    {
        $this->medias->removeElement($media);
        $media->removeTweet($this);

        return $this;
    }
87968
public function removeMediaSource($sourceId)
    {
        // ensure loaded
        $this->getMediaSources();
        unset($this->mediaSources[$sourceId]);
        $tao = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao');
        return $tao->setConfig(self::CONFIG_KEY, $this->mediaSources);
    }
1361394
public function deleteAction($id)
    {
        $delete = function($id) {
            try {
                $collectionManager = $this->getCollectionManager();
                $collectionManager->delete($id);
            } catch (CollectionNotFoundException $cnf) {
                throw new EntityNotFoundException(self::$entityName, $id); // will throw 404 Entity not found
            } catch (MediaException $me) {
                throw new RestException($me->getMessage(), $me->getCode()); // will throw 400 Bad Request
            }
        };

        $view = $this->responseDelete($id, $delete);

        return $this->handleView($view);
    }
646888
public function delete(int $id): MediaEndpointInterface
    {
        $this->shopware()->delete('/api/media/'.(string)$id);

        return $this;
    }
703357
public static function removeByIds($imageIds)
    {
        if (is_array($imageIds)) {
            foreach ($imageIds as $id) {
                if (! $id) {
                    continue;
                }

                self::remove($id);
            }
        } else {
            if (! $imageIds) {
                return;
            }

            self::remove($imageIds);
        }
    }
380583
public function removeMedia(Media $media)
	{
		$this->media->removeElement($media);
		$media->removeGallery($this);
	}
1299862
public function saveMediaCategoryAssignments(int $mediaId, array $categoryIds = null)
    {
        // Delete current category assignments for this media ID
        $this->deleteMediaCategoryAssignments($mediaId);

        // Insert all assignments, if the category ID's array is not empty
        if (null !== $categoryIds) {
            $this->sql = 'insert into media_category_map (media_id, category_id) values ';
            foreach ($categoryIds as $id) {
                $this->sql .= '(?, ?),';
                $this->bindValues[] = $mediaId;
                $this->bindValues[] = $id;
            }
            $this->sql = rtrim($this->sql, ',') . ';';
            $this->execute();
        }
    }