I have some hooks on my WordPress Theme in order to customize the default images sizes, but it does not work. Here is the code:
function my_custom_image_size() {
add_image_size( 'post_size', 730);
}
add_action( 'after_setup_theme', 'my_custom_image_size' );
// Cambia el nombre del tamano de imagen
function my_custom_image_size_name( $sizes ) {
return array_merge( $sizes, array(
'post_size' => __( 'Tamaño Post' ),
) );
}
add_filter( 'image_size_names_choose', 'my_custom_image_size_name' );
function my_default_image_size() {
update_option('image_default_size', 'post_size');
update_option('image_default_align', 'right');
}
add_action('after_setup_theme', 'my_default_image_size');
function my_remove_default_images( $sizes ) {
unset($sizes['thumbnail']); // disable thumbnail size
unset($sizes['medium']); // disable medium size
unset($sizes['large']); // disable large size
unset($sizes['medium_large']); // disable medium-large size
unset($sizes['1536x1536']); // disable 2x medium-large size
unset($sizes['2048x2048']); // disable 2x large size return $sizes;
return $sizes;
}
add_filter( 'intermediate_image_sizes_advanced', 'my_remove_default_images' );
Everything works fine but the function "my_default_image_size" does not work I don't know why. Any of these lines of code works:
update_option('image_default_size', 'post_size');
update_option('image_default_align', 'right');
When I go to a new post, the default image size is full-size and the default alignment is center. It seems a bug on "image_default_size" and "image_default_align"
When I add a new image in the sidebar appears like that:
Could anyone help me? Thanks!