Delete Image Entirely
-
So to keep my media clean I’m using this snippet:
function delete_post_media( $post_id ) { $attachments = get_posts( array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => 'any', 'post_parent' => $post_id ) ); foreach ( $attachments as $attachment ) { if ( false === wp_delete_attachment( $attachment->ID ) ) { // Log failure to delete attachment. } } } add_action('before_delete_post', 'delete_post_media');
Which deletes the media attached to a page when a page gets deleted. I was wondering if I could similarly hook into the remove image function of the slider so that when I remove the image from the slideshow, it also deletes it from the media library.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Delete Image Entirely’ is closed to new replies.