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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.