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);
}

CommentFileSizeAuthor
#3 core_image_resize.patch524 bytesfrancismak

Comments

kevin.brocatus created an issue. See original summary.

quietone’s picture

Version: 10.3.x-dev » 11.x-dev

Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.

francismak’s picture

StatusFileSize
new524 bytes

Hi,

We need to allow user to input custom width value as well.
At last, we "unlock" the resizeImage:custom by composer patching the core module. This is tested in 10.4.7.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

bramdriesen’s picture

Status: Active » Needs work

While #3 works. I think this should ideally be configurable in the ckeditor settings.