yan-k
6/7/2015 - 1:46 PM

Custom Image Size In Media Uploader add_image_size is the WordPress function that allows us to crop and display custom image size. If you w

Custom Image Size In Media Uploader

add_image_size is the WordPress function that allows us to crop and display custom image size. If you want to allow users to add image within this custom size, add the following codes to show the “custom image size” option in the WordPress media uploader.

function pw_add_image_sizes() {
    add_image_size( 'pw-thumb', 300, 100, true );
    add_image_size( 'pw-large', 600, 300, true );
}
add_action( 'init', 'pw_add_image_sizes' );
  
function pw_show_image_sizes($sizes) {
    $sizes['pw-thumb'] = __( 'Custom Thumb', 'pippin' );
    $sizes['pw-large'] = __( 'Custom Large', 'pippin' );
  
    return $sizes;
}
add_filter('image_size_names_choose', 'pw_show_image_sizes');