The "resizeImage:custom" option of the ckeditor5_imageResize plugin does not work.

Created on 1 September 2024, 3 months ago

Problem/Motivation

Instead of being able to resize images by dragging the mouse along the screen, I need to be able to provide the user with an option to set a specific width for that image (while keeping the aspect ratio). By default, the resize dropdown only provides the 'Original' option to revert it back to the original state after manually adjusting the size. By using the hook_ckeditor5_plugin_info_alter() function, I can add specific presets (50px, 100px, 200px, etc.), however if I add the 'custom' option as mentioned in the ckeditor documentation, nothing happens. The option shows up in the dropdown, I can select it, but the ckeditor input field that is supposed to pop up where you can manually enter a value never shows up. I am also not getting any errors in watchdog or my console. Since I couldn't find an alternative to setting the height/width of an image, I decided to make this bug post.

Steps to reproduce

Add the following hook to your custom module. The option will show up, but nothing will happen when you click it.

/**
* Implements hook_ckeditor5_plugin_info_alter().
*/

function mymodule_ckeditor5_plugin_info_alter(array &$plugin_definitions) {
  $plugin = $plugin_definitions['ckeditor5_imageResize']->toArray();

  $plugin['ckeditor5']['config']['image']['resizeOptions'][] = [
    'name' => 'resizeImage:custom',
    'label' => 'Custom',
    'value' => 'custom',
  ];

  $plugin_definitions['ckeditor5_imageResize'] = new CKEditor5PluginDefinition($plugin);
}

🐛 Bug report
Status

Active

Version

10.3

Component
CKEditor 5 

Last updated 1 day ago

Created by

🇳🇱Netherlands kevin.brocatus

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024