0

I'm trying to insert an image into a post from the media library, but there is no select size option in the media library when selecting an image to choose which size to insert, and the 'Image size' control is not shown in the block editor image block controls.

The image thumbnails are definitely created.

I'm using a custom theme, and I have this in the functions.php:

add_action('after_setup_theme', 'my_theme_setup');

function my_theme_setup() {
     if ( function_exists( 'add_theme_support' ) ) {
         add_theme_support( 'post-thumbnails' );
         add_image_size( 'original', '', '', true );
         add_image_size( 'large', 700, '', true );
     }
}

add_filter( 'image_size_names_choose', 'my_custom_sizes' );
 
function my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'original'  => 'Original',
        'large'     => 'Large'
    ));
}
Kadament
  • 100
  • 1
  • 8
  • 1
    When you upload image there is no option to select size. Will upload the image as it is. And depending on the image sizes defined in your theme and the default ones will resize the image if possible. – Snuffy Feb 03 '23 at 15:28
  • In most themes there is an option to choose the size of an image (within the media library) when including an image within a post. The sizes should be the ones declared in the theme as shown, but I'm unsure as to why the size option select is not showing. – Kadament Feb 06 '23 at 09:21
  • You are mixing it up. Uploading to media library and loading image in post are different things. When you upload image there is no size select since will upload the original image only and after that generates all additional sizes. When you insert in a post image you may or may not have option to select which size you want (depends on themes.plugins etc). – Snuffy Feb 06 '23 at 11:29
  • Yes that's correct - I'm speaking about 'inserting an image into a post' 'from the media library'. I don't have an option to select the size, I'm hoping to understand what I need to add to the theme that I've written to make it so that I do. I've edited OP to make more clear, thanks. – Kadament Feb 07 '23 at 12:28
  • So in other words you dont see https://wordpress.com/support/wordpress-editor/blocks/image-block/#resize-image these options ? or these https://prnt.sc/p2hmN5uzBYyZ ? – Snuffy Feb 08 '23 at 07:07
  • Yes that's correct - I can see everything with exception of 'Image size' 'Large' shown here: https://wordpress.com/support/wordpress-editor/blocks/image-block/#resize-image and also the 'Image size' 'Full size' in the second link shown. I've noticed this even with a clean install and the standard twenty-one theme, but in both instances it only happens in localhost. I'm beginning to think it could be something to do with my environment such as permissions. I don't have the issues on production server. – Kadament Feb 09 '23 at 09:26
  • @Kadament In your browser console, what is the output if you run `wp.data.select('core/editor').getEditorSettings()?.imageSizes;` ? This should return an array of the image sizes currently registered/loaded in the Editor. – S.Walsh Feb 15 '23 at 23:31

0 Answers0