Now you can set an expiry date for any upload in your WordPress media library so that when the date is reached, the files be automatically deleted from your website’s uploads directory.
Media Expirator is a great plugin for developers and anyone who needs one such type of functionality. It allows users to set expiration date for media library items, they can easily enable or disable expiration date for each uploaded file using native WordPress media editor.
Start by installing ‘Media Expirator’ plugin in WordPress
Upon activation, visit your admin area dashboard Posts -> Add New or open any old post to edit.
Click ‘Add Media’ button and upload an image (or select any pre-uploaded image file). On right panel of the thickbox, you will notice a checkbox option to enable media expiration date and text field to enter expiration date.
In order to activate expiration date on any specific media file: You simply need to tick “Set a date on which the image will be automatically deleted” and then type expiration date using YYYY-MM-DD date format. That’s it. Same can be done from your admin area dashboard Media -> Add New or Media -> Library screen.