Sample code that can be added directly into 'snippet' plugin - no need to image size plugins.
- This will create two custom image sizes and should show up in the media size dropdown selections.
// First we'll add support for featured images
// add_theme_support( 'post-thumbnails' );
// Then we'll add our 2 custom images
// add_image_size( 'featured-large', 1600, 400, true );
add_image_size( 'two-col-width', 500, 335 );
add_image_size( 'square', 200, 200, true );
// And then we'll add the custom size that spans the width of the blog to the Gutenberg image dropdown
add_filter( 'image_size_names_choose', 'jazzy_custom_image_sizes' );
function jazzy_custom_image_sizes( $sizes ) {
return array_merge( $sizes, array(
'two-col-width' => __( 'Two Col Width' ),
'square' => __( 'Square' ),
) );
}
- Once added go to Tools > Regenerate Thumbnails
(install Shortpixel https://wordpress.org/plugins/regenerate-thumbnails-advanced/ if not installed already)
https://premium.wpmudev.org/blog/wordpress-image-sizes/
Other Options/Research:
Use: Simple-image-sizes plugin
https://wordpress.org/plugins/simple-image-sizes/
Goto: Settings > Media to add/delete custom sizes.
Manual Process Docs:
https://havecamerawilltravel.com/photographer/wordpress-thumbnail-crop/
Hard Crop
/* Add new image sizes */
add_image_size( 'my200px-thumbnail', 200, 200, TRUE );
Other Options:
/*top left*/
add_image_size( 'wordpress-thumbnail', 200, 200, array( 'left', 'top' ) );
/*center left*/
add_image_size( 'wordpress-thumbnail', 200, 200, array( 'left', 'center' ) );
/*center*/
add_image_size( 'wordpress-thumbnail', 200, 200, array( 'center', 'center' ) );
ADD YOUR CUSTOM IMAGE SIZES TO THE MEDIA IMPORT SELECTOR
https://developer.wordpress.org/reference/functions/add_image_size/
https://www.makeuseof.com/tag/complete-guide-featured-thumbnails-image-sizes-wordpress/
You should change ‘your-specified-image-size` with the name that you set in the previous step.
add_filter( 'image_size_names_choose', 'my_custom_image_sizes' );
function my_custom_image_sizes( $sizes ) {
return array_merge( $sizes, array(
'your-custom-size' => __( 'Your Custom Size Name' ),
) );
}
Note: To enable featured images the current theme must include add_theme_support( ‘post-thumbnails’ ); in its functions.php file. See also Post Thumbnails.
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'your-custom-size' );
}
add_theme_support( 'your-custom-size');
add_image_ size