Support » Plugin: Easing Slider » 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)
  • Plugin Author MatthewRuddy


    Hi @howdy_mcgee, might be possible if you can hook into the “easingsliderlite_slideshow” slide’s property and loop through the arrays, searching for matched image URLs. As the plugin doesn’t store the image’s attachment ID, you won’t be able to search for it in the same way as here.

    Unfortunately I’ve never given this a try, so I don’t have a quick code snippet to provide, but feel free to give it a go and get back to me if I can be of anymore assistance 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘Delete Image Entirely’ is closed to new replies.