Support » Developing with WordPress » image block missing large image size as choice

  • Resolved Rhand

    (@rhand)


    We have thumbnails (150×150), medium(300×300) and large (1024×1024) as options at wp-admin/options-media.php but no medium large loaded there which is kind of a sweet spot we want to use use. For a Gutenberg image block I can only choose medium and full and not large.
    
    Defaults should however normally be

    'thumbnail_size_w' => 150,
    'thumbnail_size_h' => 150,
    'medium_size_w' => 300,
    'medium_size_h' => 300,
    'medium_large_size_w' => 768,
    'medium_large_size_h' => 0,
    'large_size_w' => 1024,
    'large_size_h' => 1024,

    and since 5.3

    function _wp_add_additional_image_sizes() { // 2x medium_large size.
    add_image_size( '1536x1536', 1536, 1536 ); // 2x large size. 
    add_image_size( '2048x2048', 2048, 2048 );}

    
    See https://developer.wordpress.org/reference/functions/add_image_size/

    Why does image block not offer large? Why is medium large not loaded in general at wp-admin/options-media.php?

    • This topic was modified 2 weeks ago by Rhand.
    • This topic was modified 2 weeks ago by Rhand.
    • This topic was modified 2 weeks ago by Rhand.
    • This topic was modified 2 weeks ago by Rhand.
    • This topic was modified 2 weeks ago by Rhand.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Rhand

    (@rhand)

    This code to load the medium large size image as an option found at https://wordpress.stackexchange.com/questions/290259/make-medium-large-images-available-to-insert-into-post:

    // Make medium large image size available for insertion
    add_filter( 'image_size_names_choose', 'fresh_custom_sizes' );
    function fresh_custom_sizes( $sizes ) {
       return array_merge( $sizes, array(
          'medium_large' => __( 'Medium Large' ),
       ) );
    }

    seems to not quite work as needed. Sometimes it loaded last as option, sometimes is causes all option to disappear.

    • This reply was modified 2 weeks ago by Rhand.
    Thread Starter Rhand

    (@rhand)

    This code works

    // Make medium large image size available for insertion
    // normally default and left out as option
    // https://wordpress.stackexchange.com/questions/290259/make-medium-large-images-available-to-insert-into-post
    // https://github.com/WordPress/gutenberg/issues/33010
    
    add_filter( 'image_size_names_choose', function() {
    	return [
    		'thumbnail'    => __( 'Thumbnail', 'textdomain' ),
    		'medium'       => __( 'Medium', 'textdomain' ),
    		'medium_large' => __( 'Medium Large', 'textdomain' ),
    		'large'        => __( 'Large', 'textdomain' ),
    		'full'         => __( 'Full Size', 'textdomain' ),
    	];
    } );
    • This reply was modified 2 weeks ago by Rhand.
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.