- Issue created by @kevin.brocatus
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.
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);
}
Active
10.3 ✨
Last updated