• Wonderful job with this plugin!

    I will be using it on a site with hundreds of users. Each user will be uploading photos of their children to the site (the field is part of a repeater field), what goes with that, is we’ll have thousands of photos being added to the site. Users will want to occasionally remove an image and upload a new one. I’d love to make sure that any removed images get removed from the Media library as well. Any suggestions on how to do this most efficiently?

    Thanks,
    David

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author joppuyo

    (@joppuyo)

    Hey, this is a feature that has been requested many times and I am in progress of implementing this functionality in the plugin.

    Since it needs some additional testing so everything works smoothly, I’m planning to release a new version of the plugin that has image deletion as a beta feature.

    I’ll probably release this new version next week.

    Thanks!

    Thread Starter David Bee

    (@davidbawiec)

    Fantastic! Would be happy to test and report things back! Thanks.

    Plugin Author joppuyo

    (@joppuyo)

    Hey, it took quite a bit longer thank I promised but I have included beta support for deleting unused images in the latest version of the plugin.

    I hope you are able to test it out.

    Thread Starter David Bee

    (@davidbawiec)

    Hi!

    I’m finally back and updated to the latest version of the plugin. I tested this and have good news/bad news. The good news: The deleting of the cropped version is working great. The bad news: the cropped version gets deleted as the file is being saved. So it never saves correctly. I looked through the code and looks like you save debugging info, so here’s the output.

    [13-Mar-2020 10:03:45 UTC] post_id
    [13-Mar-2020 10:03:45 UTC] user_651
    [13-Mar-2020 10:03:45 UTC] POST
    [13-Mar-2020 10:03:45 UTC] Array
    (
        [_wpnonce] => 24bb6c48eb
        [_wp_http_referer] => /wp-admin/user-edit.php?user_id=651&updated=1&wp_http_referer=%2Fwp-admin%2Fusers.php%3Fs%3D650%26action%3D-1%26new_role%26rcp_bulk_membership%255B0%255D%26rcp_bulk_membership%255B1%255D%26paged%3D1%26action2%3D-1%26new_role2
        [wp_http_referer] => /wp-admin/users.php?s=650&action=-1&new_role&rcp_bulk_membership%5B0%5D&rcp_bulk_membership%5B1%5D&paged=1&action2=-1&new_role2
        [from] => profile
        [checkuser_id] => 644
        [admin_bar_front] => 1
        [role] => customer
        [first_name] => Celine
        [last_name] => Dion
        [nickname] => Celine Dion
        [display_name] => Celine Dion
        [description] => Near, far, wherever you are, I believe that the heart does go on. Once more you open the door And you\'re here in my heart And my heart will go on and on.
        [pass1] => 
        [pass2] => 
        [_acf_screen] => user
        [_acf_post_id] => user_651
        [_acf_validation] => 1
        [_acf_nonce] => 
        [_acf_changed] => 1
        [aiarc_temp_post_id] => 80f69d32-91c8-47fa-96e2-84ce82250c64
        [acf] => Array
            (
                [field_5e1d6e4b050e2] => No preference
                [field_5df8aecc1a7d5] => no
                [field_5e6ad5f5accbe] => Array
                    (
                        [0] => English
                    )
                [field_5d9028ca99a6b] => Array
                    (
                        [row-0] => Array
                            (
                                [field_5d95802b1d09a] => 7949
                                [field_5d9028f299a6c] => Jim
                                [field_5d90293299a6d] => 20190417
                                [field_5d95b713e50c0] => he/him/his
                                [field_5daea36c0f941] => Male
                                [field_5daeb2f0b40bc] => 
                                [field_5daeb5d1895ea] => 0
                                [field_5daca11bbc30b] => 
                                [field_5d90298e99a6e] => 
                                [field_5d9029f199a6f] => Adorable. Loves singing.
                                [field_5e6704dbc7037] => 5e6706cb39068
                            )
    
                        [row-1] => Array
                            (
                                [field_5d95802b1d09a] => 9596
                                [field_5d9028f299a6c] => Jack Jack
                                [field_5d90293299a6d] => 20070419
                                [field_5d95b713e50c0] => they/them/theirs
                                [field_5daea36c0f941] => Non-binary
                                [field_5daeb2f0b40bc] => 
                                [field_5daeb5d1895ea] => 0
                                [field_5daca11bbc30b] => 
                                [field_5d90298e99a6e] => 
                                [field_5d9029f199a6f] => The black sheep of the family. Will not listen to anything you say unless you give him cheesecake. Be careful. Sometimes self-combusts.
                                [field_5e6704dbc7037] => 5e6706cb3e545
                            )
    
                        [row-2] => Array
                            (
                                [field_5d95802b1d09a] => 7954
                                [field_5d9028f299a6c] => Clair
                                [field_5d90293299a6d] => 20151028
                                [field_5d95b713e50c0] => she/her/hers
                                [field_5daea36c0f941] => Female
                                [field_5daeb2f0b40bc] => Array
                                    (
                                        [0] => Autism Spectrum
                                        [1] => Intellectual / Cognitive
                                    )
    
                                [field_5daeb3feb40bd] => Needs assistance getting up from the sofa. Please don\'t make loud noises as they may scare her.
                                [field_5daeb5d1895ea] => 1
                                [field_5daeb7481e818] => Fluffy
                                [field_5daca11bbc30b] => 
                                [field_5d90298e99a6e] => Allergic to squirrels.
                                [field_5d9029f199a6f] => She really loves squirrels.
    So there\'s the problem... ;)
                                [field_5e6704dbc7037] => 5e6706cb447a0
                            )
    
                    )
    
                [field_5daf6d90597b0] => 
                [field_5e6aee753ee1b] => 
                [field_5e18760202024] => https://facebook.com/celinedion
                [field_5e18760202059] => https://twitter.com/celinedion
                [field_5e18760202083] => https://www.instagram.com/celinedion
                [field_5e187602020af] => https://youtube.com/celinedion
            )
    
        [app_name] => 
        [app_email] => 
        [app_phone] => 
        [app_address] => 
        [app_city] => 
        [wpfront-secondary-roles] => Array
            (
                [wpamelia-customer] => on
                [wpamelia-provider] => on
            )
    
        [wp-user-avatar] => 7914
        [action] => update
        [user_id] => 651
        [submit] => Update User
    )
    
    [13-Mar-2020 10:03:45 UTC] found following post attachments
    [13-Mar-2020 10:03:45 UTC] Array
    (
        [0] => WP_Post Object
            (
                [ID] => 9596
                [post_author] => 644
                [post_date] => 2020-03-13 06:03:21
                [post_date_gmt] => 2020-03-13 10:03:21
                [post_content] => 
                [post_title] => jackjack-aspect-ratio-1x1
                [post_excerpt] => 
                [post_status] => inherit
                [comment_status] => open
                [ping_status] => closed
                [post_password] => 
                [post_name] => jackjack-aspect-ratio-1x1
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2020-03-13 06:03:21
                [post_modified_gmt] => 2020-03-13 10:03:21
                [post_content_filtered] => 
                [post_parent] => 0
                [guid] => https://local.###############.com/jackjack-aspect-ratio-1x1/
                [menu_order] => 0
                [post_type] => attachment
                [post_mime_type] => image/jpeg
                [comment_count] => 0
                [filter] => raw
            )
    
    )
    
    [13-Mar-2020 10:03:45 UTC] found following fields
    [13-Mar-2020 10:03:45 UTC] Array
    (
        [field_5e1d6e4b050e2] => No preference
        [field_5df8aecc1a7d5] => no
        [field_5e6ad5f5accbe] => Array
            (
                [0] => English
            )
        [field_5d9028ca99a6b] => Array
            (
                [row-0] => Array
                    (
                        [field_5d95802b1d09a] => 7949
                        [field_5d9028f299a6c] => Jim
                        [field_5d90293299a6d] => 20190417
                        [field_5d95b713e50c0] => he/him/his
                        [field_5daea36c0f941] => Male
                        [field_5daeb2f0b40bc] => 
                        [field_5daeb5d1895ea] => 0
                        [field_5daca11bbc30b] => 
                        [field_5d90298e99a6e] => 
                        [field_5d9029f199a6f] => Adorable. Loves singing.
                        [field_5e6704dbc7037] => 5e6706cb39068
                    )
    
                [row-1] => Array
                    (
                        [field_5d95802b1d09a] => 9596
                        [field_5d9028f299a6c] => Jack Jack
                        [field_5d90293299a6d] => 20070419
                        [field_5d95b713e50c0] => they/them/theirs
                        [field_5daea36c0f941] => Non-binary
                        [field_5daeb2f0b40bc] => 
                        [field_5daeb5d1895ea] => 0
                        [field_5daca11bbc30b] => 
                        [field_5d90298e99a6e] => 
                        [field_5d9029f199a6f] => The black sheep of the family. Will not listen to anything you say unless you give him cheesecake. Be careful. Sometimes self-combusts.
                        [field_5e6704dbc7037] => 5e6706cb3e545
                    )
    
                [row-2] => Array
                    (
                        [field_5d95802b1d09a] => 7954
                        [field_5d9028f299a6c] => Clair
                        [field_5d90293299a6d] => 20151028
                        [field_5d95b713e50c0] => she/her/hers
                        [field_5daea36c0f941] => Female
                        [field_5daeb2f0b40bc] => Array
                            (
                                [0] => Autism Spectrum
                                [1] => Intellectual / Cognitive
                            )
    
                        [field_5daeb3feb40bd] => Needs assistance getting up from the sofa. Please don\'t make loud noises as they may scare her.
                        [field_5daeb5d1895ea] => 1
                        [field_5daeb7481e818] => Fluffy
                        [field_5daca11bbc30b] => 
                        [field_5d90298e99a6e] => Allergic to squirrels.
                        [field_5d9029f199a6f] => She really loves squirrels.
    So there\'s the problem... ;)
                        [field_5e6704dbc7037] => 5e6706cb447a0
                    )
    
            )
    
        [field_5daf6d90597b0] => 
        [field_5e6aee753ee1b] => 
        [field_5e18760202024] => https://facebook.com/celinedion
        [field_5e18760202059] => https://twitter.com/celinedion
        [field_5e18760202083] => https://www.instagram.com/celinedion
        [field_5e187602020af] => https://youtube.com/celinedion
        [field_5db1289e27c55] => Array
            (
                [row-0] => Array
                    (
                        [field_5db128c827c56] => Samantha
                        [field_5db1290727c57] => Sister
                    )
    
            )
    
    )
    
    [13-Mar-2020 10:03:45 UTC] preserve ids
    [13-Mar-2020 10:03:45 UTC] Array
    (
    )
    
    [13-Mar-2020 10:03:45 UTC] all ids
    [13-Mar-2020 10:03:45 UTC] Array
    (
        [0] => 9596
    )
    
    [13-Mar-2020 10:03:45 UTC] delete ids
    [13-Mar-2020 10:03:45 UTC] Array
    (
        [0] => 9596
    )
    
    

    It looks like the $preserve_ids ends up being empty. Which is probably part of the cause of the problem.

    Let me know what you find!
    Thanks!
    David

    Thread Starter David Bee

    (@davidbawiec)

    On a side note, while you’re checking this out, one more thing I did notice is that what gets deleted are the cropped versions, not the original uploads or the various thumbnails. This may be an issue with the bug described above. But while you’re looking, can you make sure that original versions will also get deleted?

    Thanks!
    David

    Plugin Author joppuyo

    (@joppuyo)

    Hey David,

    I have identified a bug with nested fields (such as repeaters) and the option to delete the unused version. I just published a new version of this plugin on WordPress.org which fixes this issue.

    Could you check that you are now able to change the image?

    Right now I’m not planning to add a feature to delete the original image. The whole process is dependant on the original image being available, for example, re-cropping an image would not be possible if we simply delete the original after cropping is complete.

    I’m planning on adding a feature so you can select which thumbnail sizes are generated. This is a separate issue from this but I hope this could help with the problem you are having with too many images being generated.

    Johannes

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Delete Removed Images from Media Library’ is closed to new replies.