Is there a reason you need to delete them first? You can use Regenerate Thumbnails if you need to generate new image sizes after switching themes or registering a new image size.
https://wordpress.org/plugins/regenerate-thumbnails/
This plugin also gives you an option to delete images related to unregistered sizes.
Note: the plugin is not tested with the last few releases of WordPress
Related Posts:
- How to make programmatic image upload generate thumbnail and sizes?
- Upload media files to Amazon S3
- Is it possible to change image size used for preview thumnail in Add Media popup
- Why WordPress suddenly changed sizes of thumbnails?
- unsharp thumbnails after uploading image
- WP is showing wrong image dimensions
- Restricting users to view only media library items they have uploaded?
- Set default image link target in Gutenberg image block
- Is there a hook which fires after all thumbnails are generated?
- Using Images in WordPress – Best Practices
- How to set the default embed image size
- get_the_post_thumbnail_url with an unregistered size
- Cropped featured image replaces original image in gallery
- Settings in ‘Media > Settings’ is ignored when inserting images
- How do I delete all generated images from my server except those currently used in posts
- How do i upload an image and return the image id?
- Upload images using FTP and show them in media
- Cannot access the thumbnails of attachment images… Cannot find the reason
- Add visual editor to Media Edit Screen
- Removing Title Tag from Thumbnails
- custom image size with New Media Manager in wordpress 3.5
- Disable wordpress image sizes generation
- Can’t access ‘Store uploads in this folder’
- How to add qtranslate multi language support for media?
- 3.5 media.editor: what is the event listener for choosing an image?
- Display latest 12 images from media library
- Rename media files generated during upload
- Thumbnails are bigger in size than the original image
- Link to full size image or attachment page in photo theme
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- How Do I Delete All The Images from WordPress
- Lazyload post thumbnails
- image in my post disappeared after I upload website to remote server
- Handling image uploads without thickbox
- Pull images from the gallery
- How to stop thumbnail generation from some images and different size thumbnail generate
- Update old Post image metadata to ‘thumbnail’ wp_attached_file
- How to stop wordpress always displaying full-res images
- How to change image atributes right before an image to be saved?
- Is it possible to change ‘Link to’ in all images in all articles?
- Searching for any images in media library displays “no media found”
- Ho to add “Create Slider” option to default “Add Media” popup?
- How to filter the image embed code based on link type
- Why it doesn’t show media urls on rest Api? (WordPress)
- How to get file URL from media library
- Edit image results in copies of file being created
- Fixing image names for a site being restored
- force feed readers to pick atom version
- Images uploaded to the media library has strange colors. However, in the edit screen the color is ok
- Blank upload.php page
- Export xml use/import images from theme directory
- Upload box media size not working
- Dynamic image crop in WP 3.0+?
- Automatically Insert alt attribute above image has h2
- Rebuild thumbnails via WP Cli – how?
- Auto delete pictures in media library by age
- Can we use featured image as third party website image URL
- WordPress Attachments with old images
- add_image_size not working
- Disable Media File Image Link On Mobile Devices
- Product Images Low Quality After Updating From WP 3.5 to 4 [closed]
- adding image to post thumbnail from another server
- Set Featured Image not opening – Stuck at loading
- How to remove “Image Information” and “post date/author” from a media page?
- Broken thumbnails (sometimes) with TimThumb
- Is it possible to save crop to a different size of the image when in image editor?
- Profile image does not upload
- cant upload media/pictures to my wordpress site, cant upload anything to my database
- Apply manual image cropping not to thumbnail but medium_large size
- How to display the Media Library Items Upload date
- Images not showing after wordpres update 5.6
- Upload error on localhost (at minimum, not yet tested online)
- How to use default image as featured image by implement some code in function.php
- Auto Generate Thumbnail
- Images not loading on webpage, and links to other media give 404 Not Found
- WordPress Multisite: Images moved to /sites/1?
- ADD class to all my images (thumbail)
- I cannot upload images to post or the media library in wordpress
- Generate links on all images in posts – is there a hook?
- How to disable post-thumbnail from generation?
- Use wget to find used images
- WordPress can’t detect any thumbnails size?
- wordpress images not showing properly
- Edit image itself
- How Do I Auto Generate Thumbnail from First Embedded Image?
- Why doesn’t WordPress make thumbnails for videos?
- How do I display image files as links?
- page displaying media caption shortcodes
- Missing Images in Uploads Directory (Server Only)
- Broken Media Library
- Making a thumbnail if there exist a link with. jpg or .png extension in WordPress
- Imagem resolution responsive
- Aviary + WordPress Media
- Media Library is not loading on grid view in admin panel
- How to include featured image on blog post preview?
- Why some images are not allowed to be edited only for thumbnails?
- Thumbnail size keeps resetting automatically
- WordPress API, creating Featured Media from image url (nodejs)
- Media Library shows default image instead of image preview
- Uploading media to wordpress API with C# HttpClient