WordPress.org

Ready to get started?Download WordPress

Forums

Easing Slider "Lite"
Delete Image Entirely (2 posts)

  1. Howdy_McGee
    Member
    Posted 11 months ago #

    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.

    http://wordpress.org/plugins/easing-slider/

  2. MatthewRuddy
    Member
    Plugin Author

    Posted 10 months ago #

    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 :)

Reply

You must log in to post.

About this Plugin

About this Topic