Support

Account

Home Forums Add-ons Gallery Field Delete All Images In Gallery At Once Reply To: Delete All Images In Gallery At Once

  • Thanks. I managed to resolve this myself thanks to your advice.

    For anyone who is interested, I just did the following:

    
    function clear_button( $field ) {
    
    	echo '<p><a href="#" class="acf-button button button-primary acf-gallery-clear">Clear Images</a></p>';
    
    }
    add_action( 'acf/render_field/type=gallery', 'clear_button', 10, 1 );
    
    function my_acf_input_admin_footer() {
    	
    ?>
    <script type="text/javascript">
    (function($) {
    	
    	$('.acf-gallery-clear').click(function() {
      $('.acf-gallery-remove').click();
    });
            
    })(jQuery);	
    </script>
    <?php
    		
    }
    
    add_action('acf/input/admin_footer', 'my_acf_input_admin_footer');
    

    This just clears the images from the gallery rather than deletes them off the website which I may do in the future but for now I just needed a way of starting again with the gallery.