With this method you will be able to delete broken images from your database and from your wordpress library. The links will be deleted with the the non existed images. But the links in your Pages will remain the same unless you edit your page and delete the links from there.
When you are adding an image in your post or a page or upload them in your wordpress website, they all get stored in your library. After you delete the photos from your page or post, the photo will remain in your wordpress library. Sometimes due to broken plugins or un-optimised wordpres site some of these photos get not deleted properly. So these images show up as a photo in library but they are not logically exist in your upload folder. So Deleting these broken images will speedup your website.
Below is the instruction on how to clean your library.
Installing Imagify plugin
1. Go to plugins
2. Add plugins
3. Search for imagify
4. Install and activate
5. Click on imagify
6. You may need to buy a plan from imagify. So you will be able to optimise all ofyour photos with imagify. Although at the Moment with free plan with imagify you can optimise 100 photos a month.
7. You may need to wait sometime now to optimise all your photos.
8. Now visit your library and you will notice a new column in your library as imagify
9. Compare the Optimised existed images to non-optimised and non-existed.
On the below photo you will see first item that has no thumbnail photo and its not optimised. On the second circled photo you see that the photo has a thumbnail and its optimised as well. So here you will know that the first photo is not existed but its record exist in your library same in database.
10. So you main job starts here, you need to check them all and delete them permanently.
11. On below photo you can click on optimisation button and you will find out that you can’t optimise this photo as its not logically exists in your library.
12. You can also click on “View” option to find out and see the non optimised photo does not exist at all.
13. Select all Photos that can’t be optimised and they couldn’t be found and Delete Permanently
Check out this video for more information on how to remove broken images in your wordpress website