Change default "Apply Changes To" radio option when editing images

I have a theme where when the user edits images, I want the changes to apply to "all sizes except for thumbnails".

She remembers to check this box most of the time, but not always, and it is very aesthetically unappealing on one page when she doesn't. Also; it's kind of a pain for here to have to check the box every time.

I found in /wp-admin/includes/image-edit.php where the default is set -> happens on line 133 with:

input type="radio" name="imgedit-target-?php echo $post_id; ?" value="all" checked="checked" /
        ?php _e('All image sizes'); ?/label

But I'm kind of new to WP, and I don't really know what to do with this knowlege. It's easy enough to implement in the front or the backend; I just haven't figured out when, where, or how.

Any help?

Topic radio cropping images customization Wordpress

Category Web


It is hopeless to hook into the image-edit.php ajax loaded screen. This issue, to pre-select "thumbnail only" radio option instead of "all images" can be solved by jQuery. The snippet in your functions.php can be improved, but works:

// Populate thumbnail settings
function entex_admin_image_editor_activate_tweaks() {
    ?>
<script type="text/javascript">
    jQuery(document).ready(function($) {
        $(document).ajaxStop(function(){
            if($('.imgedit-settings input[value="thumbnail"]').get(0)) {
                $el = $('.imgedit-settings input[value="thumbnail"]');
                if($el.data('manipulated')) return;
                $el.data('manipulated', true);
                $el.prop('checked', true).parent().siblings().find('input').prop('checked', false);
            }
        });
    });
</script>
    <?php
}

function entex_admin_image_editor_current_screen($screen){
    if($screen->base != 'post' || $screen->post_type != 'attachment') return;
    add_action('admin_footer', 'entex_admin_image_editor_activate_tweaks');
}
add_action('current_screen', 'entex_admin_image_editor_current_screen');

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.