How to remove media by filename?

Question

For some reasons, when I´m doing an import of data to make posts and medias, I can have :

  1. Some media not attached but with an image
  2. Some files still saved in uploads folder but not visible in Library
  3. Some media not attached but without image

The common point is the filename so,

how can I add in my php script to remove media/files by filename like :

  1. If there is a media with this filename, remove it with the file if exists
  2. If there is no media but the file is physically in the uploads directory, remove the file
0
, J.BizMai 3 years 2020-07-05T10:10:45-05:00 0 Answers 71 views 0

Leave an answer

Browse
Browse