To add a custom image size to your WordPress simply add the following code to your functions.php
In addition to creating the image size, the filter will also make the image available in the editor so that you can select it. Finally, make sure that you regenerate the thumbnails so that your existing images will be recreated in the correct size.
1 2 3 4 5 6 7 8 9 10 11 | if ( function_exists( 'add_image_size' ) ) { add_image_size( 'square-medium', 240, 240, true ); //(cropped) } add_filter('image_size_names_choose', 'my_image_sizes'); function my_image_sizes($sizes) { $addsizes = array( "square-medium" => __( "Square Medium") ); $newsizes = array_merge($sizes, $addsizes); return $newsizes; } |