Problem/Motivation
When using "Insert from Media Library" from CKEditor if you could specify width/height of media either by entering values on edit modal or by dragging handle (like "Insert Image" works) would be nice.

How to on fresh install using Bartik theme:

  • Enable Media and Media Library core module
  • Edit text format (admin/config/content/formats) to include "media" to include "Insert from Media Library" icon to "Active toolbar" and enable filter "Embed media" with filter settings set to "Image" for "Media types selectable in the Media Library" and "Media library" for "View modes selectable in the 'Edit media' dialog".
  • Create new content using Article (default) and using new media icon upload and insert image to CKEditor.
  • Currently "Edit media" modal has fields for "Alternate text", "Align" and checkbox "Caption". Having fields for width and height here would be useful. See attached image.

Comments

igorbiki created an issue. See original summary.

kpaxman’s picture

This would be essential for us. I think without this we're forced into using the "image" file type instead of media when we're inside CKeditor and it would really be nice to just have the one source (and we're using media elsewhere).

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

wim leers’s picture

Issue tags: +Media Initiative

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

kpaxman’s picture

Note that this module allows this: https://www.drupal.org/project/media_embed_extra

Would love some direction on whether or not this is likely to come to core.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

+1 this feature would be great. That module makes me nervous that it's not supported so being part of core would be great.

rar9’s picture

+1 for adding width +height ... it would help to get a better lighthouse score as well.

digitaltodd’s picture

+2 for adding width+height - works in drupal 7

ericdsd’s picture

It would be great in core eg when you have a small badge to include aside from the text and that it cannot be managed by a fixed structure. Even if it's not the cleanest way to do it's hard to explain a client that drupal doesn't allow to resize a picture ;-)

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

sudesh.solaskar’s picture

StatusFileSize
new20.53 KB

Hello Guys,

I have created an patch that supports resize feature of normal image upload to the media embedded image. By applying this patch we can resize the images coming from media library as well. Request you all to review this patch

sudesh.solaskar’s picture

Status: Active » Needs review
sudesh.solaskar’s picture

StatusFileSize
new12.89 KB

Hello Guys, the previous patch was generated on 8.9.x branch. Here is the patch generated on 9.4.x branch

sudesh.solaskar’s picture

StatusFileSize
new12.71 KB

All of the above patches are getting failed because of the path mapping. Here i am attaching the finalized patch.

sudesh.solaskar’s picture

StatusFileSize
new12.8 KB

Hello, I have just updated few style related issue of edit icon positioning.

Justin Langley’s picture

When using the patch in #17, it doesn't appear to fully work. I can resize the image, but as soon as the handle is released the image reverts to it's original size. It appears the data- attributes on the drupal-media element update, but the img inside always reverts to it's original size inside the editor.

sudesh.solaskar’s picture

Hello @justin, You will have to add data-height & data-width attributes to the allowed tags list of ckeditor.

gauravvvv’s picture

Re-rolled patch #17, es6.js file was not updated in earlier patch. Please review.

gauravvvv’s picture

StatusFileSize
new17.88 KB
efes’s picture

Is it possible to release this functionality for 9.3.x too?

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

zunzun’s picture

File Size
3132211_drupal_media_ckeditor_resize_17.patch 12.8 KB
9.4.x: PHP 8.0 & MySQL 5.7 Custom Commands Failed
interdiff-3132211-17_20.txt 20.86 KB
Re-rolled patch #17, es6.js file was not updated in earlier patch. Please review.

Thanks @Gauravmahlawat. it's working to me.

smustgrave’s picture

Status: Needs review » Needs work

The last patch is failing existing tests

Also will need it's own moving to NW for that.

quietone’s picture

Project: Drupal core » CKEditor 4 - WYSIWYG HTML editor
Version: 9.5.x-dev » 1.0.x-dev
Component: ckeditor.module » Code

CKEditor has been removed from core, CKEditor 4 is removed from Drupal Core in 10.0.0

andrea.cividini’s picture

Patch #21 is not complete and not working for me on 9.4.7.
If we compare the patch content, the last one is missing the `setupResizer(_this3);` call that actually enables the resizer on the image. The previous one does work.
`

cilefen’s picture

Is this issue also covering CKEditor 5?

g-brodiei’s picture

Looking forward to see this happen on CKEditor4 and CKEditor5!

timovos’s picture

Transformed the patch #17 into a working patch for Drupal 9.5.x. Needed to patch core and ckeditor module, so two patches are made.

nelo_drup’s picture

#30 patch is compatible with entity embed?

crutch’s picture

-

omsingh89’s picture

Unable to apply patch ckeditor-enable-image-resize.patch #30
Drupal Core: 9.5.3, PHP: 8.1

omsingh89’s picture

StatusFileSize
new11.38 KB

Transformed the patch #17 into a working patch for Drupal 9.5.x. For Media Core module patch use 'user media-enable-image-resize.patch' patch from #30, and created a new patch for CKEditor 4 Contrib module: 3132211_drupal_ckeditor_4_resize.patch

gauravvvv’s picture

nelo_drup’s picture

#34 Thanks for updating the patch, although I think a module as such would be better for that, both for media and for what does not use media

omsingh89’s picture

Is it possible to release this functionality for Ckeditor 5?

rutiolma’s picture

Note that this concerns ckeditor4 only.
For ckeditor there's already a working module ckeditor_media_resize