Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Blogging & content · Guide

How to Delete Media in WordPress (Step by Step)

How to Delete Media in WordPress (Step by Step)

Short answer

Go to Media > Library, click the file and choose Delete permanently, then confirm. To remove several files, click Bulk select in grid view, pick the files and click Delete permanently. WordPress deletes the file and its image sizes for good, and it does not remove the image from posts that still use it.

Key takeaways

  • Single files are deleted from the Attachment details window with Delete permanently.
  • Bulk select in grid view or Bulk actions in list view removes many files at once.
  • Media skips the trash unless you add MEDIA_TRASH to wp-config.php.
  • Deleting a file does not update posts, so check where it is used first.
  • Delete through the library, not FTP, so the database stays in step.
  • Back up before running any unused-media cleanup.

How do you delete a single media file in WordPress?

Go to Media > Library, click the file to open its details, then click Delete permanently and confirm the warning.

Here are the steps in the default grid view:

  1. In your dashboard, go to Media > Library.
  2. Click the image, video or document you want to remove.
  3. The Attachment details window opens.
  4. Click the red Delete permanently link near the bottom.
  5. Click OK in the browser pop-up to confirm.

The file disappears from the library right away. WordPress also removes the extra image sizes it created when you uploaded it, such as thumbnail and medium.

WordPress describes this screen in its Media Library documentation. If you are unfamiliar with the library itself, our explainer on what the Media Library is covers the basics.

How do you delete several media files at once?

In grid view, click Bulk select, pick the files, then click Delete permanently; in list view, tick the boxes and use the Bulk actions menu.

Grid view method:

  1. Go to Media > Library.
  2. Click Bulk select above the grid.
  3. Click each file you want to remove. Selected files show a check mark.
  4. Click Delete permanently and confirm.

List view method:

  1. Click the list icon next to the grid icon at the top of the library.
  2. Tick the checkbox beside each file.
  3. Open the Bulk actions dropdown and choose Delete permanently.
  4. Click Apply and confirm.

List view is handy for big clean-ups. You can sort by date, filter by file type and see which post each file was uploaded to.

Does deleting media in WordPress remove it from posts?

No, deleting a file does not edit your posts, so any page still using it will show a broken image or a dead download link.

WordPress removes the file from the server and its record from the database. It does not search your content to remove references.

Before you delete, check where the file is used. The Uploaded to column in list view shows the post the file was first attached to. That is only a starting point, because you can reuse the same image anywhere.

Search your site for the file name to find other uses. Also check:

  • Featured images on posts and products
  • Site logo and site icon
  • Page builder templates and headers
  • WooCommerce product galleries
  • Widgets and menus

If you delete an image by mistake, you will need to upload it again and add it back to each page. Our guide on replacing a media file shows a safer way to swap images without breaking links.

Is there a trash for media files in WordPress?

Not by default; media skips the trash and is deleted permanently, but you can turn on a media trash by adding one line to wp-config.php.

Add this line above the comment that says to stop editing:

define( 'MEDIA_TRASH', true );

After that, the library shows Trash instead of Delete permanently. Trashed files can be restored for a while before WordPress empties the trash.

This setting is worth turning on if several people manage your media. It gives you a safety net against accidental deletes.

What happens to the files on your server when you delete media?

WordPress removes the original upload and every generated size from the wp-content/uploads folder, along with the attachment record in the database.

Behind the scenes, WordPress calls the wp_delete_attachment function. It deletes the attachment post, its metadata and the files on disk.

What gets removedWhere it lived
Original filewp-content/uploads/year/month
Generated sizes (thumbnail, medium, large and others)Same uploads folder
Attachment post and metadataWordPress database
References in postsNot removed; links break

If you use a CDN or an offload plugin that stores media in cloud storage, check its settings. Some remove the remote copy too, while others keep it.

Why should you not delete media files with FTP?

Deleting through FTP or a file manager removes the file but leaves its record in the database, so the library shows broken entries with missing previews.

Always delete through the Media Library when you can. That keeps the database and the files in step.

If you already removed files by FTP, delete the broken entries in the library afterwards. A media cleanup plugin can also find database entries that no longer have a file.

How do you find and delete unused media?

Use a media cleanup plugin to scan for files that are not used in your content, review the list carefully, and back up before you delete anything.

A tool like Media Cleaner scans posts, pages and common plugins to flag files that appear unused. No scanner is perfect, though. Files used in custom code, theme options or some page builders can be flagged by mistake.

A safe process:

  1. Take a full backup of files and database.
  2. Run the scan.
  3. Review the results by hand, especially logos, icons and background images.
  4. Move flagged files to the plugin's trash first if it offers one.
  5. Browse the site, then empty the trash.

Our guide on how to back up a WordPress site covers backup options.

For a wider tidy-up, see how to clean up a WordPress site.

Can you delete media with WP-CLI?

Yes, attachments are posts, so you can list them with wp post list and delete them with wp post delete using the --force flag.

To list media items:

wp post list --post_type=attachment --fields=ID,post_title,post_date

To delete one by its ID:

wp post delete 123 --force

The --force flag deletes the attachment and its files for good. Without it, WordPress tries to send the item to the trash. See the WP-CLI post delete reference for all options.

Run commands like these on a staging site or after a backup. There is no undo.

Why can't you delete a media file in WordPress?

You may lack permission for that file, a plugin may be blocking the request, or the media library itself may not be loading properly.

Common causes:

  • User role. Authors can usually delete only files they uploaded. Editors and administrators can delete any file.
  • Server file permissions. If WordPress cannot write to the uploads folder, the database entry may go but the files stay.
  • Plugin conflicts. Security, offload or media plugins can interfere with delete requests.
  • Library errors. If the grid never loads, deletion buttons will not work either.

If the library spins forever or shows errors, follow our guide to fixing the media library not loading first.

How do you delete media on WordPress.com?

The steps are almost the same on WordPress.com: open the Media section, select one or more files and choose delete, then confirm.

WordPress.com uses its own media screen on some plans, but the idea matches self-hosted WordPress. You select files, click delete and confirm. See the WordPress.com media support page for the current screens on your plan.

As with self-hosted sites, deleting a file does not remove it from posts that use it. Check your pages afterwards for broken images.

How do you stop the library filling up with unwanted files?

Upload only the images you need, resize them before uploading, and give each file a clear name so you can find and remove it later.

Every image you upload creates several extra sizes on the server. A single photo can turn into five or more files. Over a few years, that adds up to gigabytes.

A few habits help:

  • Resize large photos to the width your theme actually uses before uploading.
  • Name files clearly, such as red-running-shoes.jpg instead of IMG_4471.jpg.
  • Delete test uploads and rejected images straight away.
  • Review the library every few months with list view sorted by date.

These habits make future clean-ups quick and lower the chance of deleting something important by mistake.

Does deleting media make your site faster?

Deleting unused files saves disk space and makes backups smaller, but it rarely changes how fast your pages load for visitors.

Page speed depends on the files a page actually uses. Unused uploads just sit on disk.

If speed is your goal, compress and resize the images you do use. Our guide on optimizing images for WordPress explains what makes the real difference.

Frequently asked questions

Can I recover a deleted image in WordPress?

Not from the dashboard, because media is deleted permanently by default. You can restore it from a backup of your uploads folder and database, or upload the original again and re-add it to your pages. Turning on MEDIA_TRASH prevents this problem in future.

Does deleting an image remove all its sizes?

Yes. When you delete through the Media Library, WordPress removes the original file and every size it generated, such as thumbnail, medium and large. Sizes created by some plugins or themes outside the normal process may need a cleanup plugin.

How do I delete all media in WordPress at once?

Switch to list view, set the number of items per page higher in Screen Options, select all with the top checkbox and use Bulk actions to delete permanently. Repeat for each page. Back up first, because this cannot be undone.

Why does my deleted image still show on my site?

A cache plugin, your host's cache, a CDN or your browser may still be serving an old copy. Clear each cache layer. If the image loads from a cloud storage service, the remote copy may not have been removed.

Can authors delete media in WordPress?

Authors can usually delete media files they uploaded themselves but not files uploaded by other users. Editors and administrators can delete any file in the library. Custom roles or membership plugins may change these permissions.

Sources

  1. Media Library Screen WordPress.org
  2. wp_delete_attachment() WordPress Developer Resources
  3. wp post delete WP-CLI Commands
  4. Media Cleaner WordPress.org Plugin Directory
  5. Media WordPress.com Support
  6. Delete media in WordPress GoDaddy Help

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.