transmitstudio
8/24/2015 - 10:06 PM

Manually define image sizes and add them to Media insertion tool dropdown

<?php
// Add our custom image sizes
add_image_size( 'Featured Image', '350', '200', array( "1", "") ); 
add_image_size( 'slider', '1148', '400', array( "1", "") ); 
add_image_size( 'department-slider', '810', '360', false ); 
add_image_size( 'featured-image', '350', '200', false );

// Add custom image sizes to Media insertion dropdown menu
/*add_filter('image_size_names_choose', 'xmit_image_sizes');
function xmit_image_sizes($sizes) {
  $addsizes = array(
    "featured-image" => __( "Featured Image"),
    "department-slider" => __( "Department Slider"),
    "slider" => __( "Slider")
  );
  $newsizes = array_merge($sizes, $addsizes);
  return $newsizes;
}*/
// here's a more efficient way to do this
add_filter( 'image_size_names_choose', 'westfacecp_custom_image_sizes_callback' );
function westfacecp_custom_image_sizes_callback( $sizes ) {
    return array_merge( $sizes, array(
        'wfcp-post-thumbnail' => __( 'WFCP Post Thumbnail' ),
        'wfcp-medium' => __( 'WFCP Medium' ),
        'wfcp-large' => __( 'WFCP Large' ),
        'wfcp-internal-page-header' => __( 'WFCP Internal Page Header' ),
        'wfcp-sidebar-thumb' => __( 'WFCP Sidebar Thumb' ),
    ) );
}
?>