Register Custom Image Size (Editor-Selectable)
Registers a 600x400 hard-cropped "Card" image size and adds it to the block editor image size dropdown.
PHPby SnipCraft
php
<?php
if ( ! function_exists( 'scseed_register_card_image_size' ) ) {
function scseed_register_card_image_size() {
add_image_size( 'scseed-card', 600, 400, true );
}
add_action( 'after_setup_theme', 'scseed_register_card_image_size' );
}
if ( ! function_exists( 'scseed_add_card_size_to_editor' ) ) {
function scseed_add_card_size_to_editor( $sizes ) {
$sizes['scseed-card'] = __( 'Card (600x400)', 'scseed' );
return $sizes;
}
add_filter( 'image_size_names_choose', 'scseed_add_card_size_to_editor' );
}#block-editor#editor#images#media