WordPress allows us to delete posts, pages, or WooCommerce product pages, but the media library still retains all of the content’s images. Although it can be set aside for later use, the disadvantage is that it will use host resources.
After deleting articles, pages, or WooCommerce product pages, the “Autoremove Attachments” plug-in can assist us in automatically eliminating the images in the content.
It strictly refers to all “attachments” (such as PDF files) within the content.
Auto remove Attachments is a free plug-in, the download page on WordPress’s official website is: https://wordpress.org/plugins/autoremove-attachments/