0

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?

  • You shouldn't be editing core WordPress files, you can use filters to manage such requirements. – Alexander Gounder Aug 5 '15 at 19:40
  • @AlexanderGounder: I'm clear about this. Can you tell me how I can use filters to achieve this? Or at least point me in the right direction. – dgo Aug 5 '15 at 22:09
0

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.