When uploading an image, the height & width are initially set to the image's dimensions. Some of our novice users are uploading massive images and click OK to insert it onto the page without first setting a reasonable size. The image fills the entire editor, pushes their text down and they can't see what they're doing.

It would be helpful if an initial maximum size could be defined for new images.

This would also help the image_resize_filter to do what it's supposed to do.

Comments

bwaindwain created an issue. See original summary.

bwaindwain’s picture

Status: Active » Needs review
StatusFileSize
new3.02 KB

Here's a patch which listens to the image2 dialog's src field change event and limits the dimensions.

It expects two config variables. Set these in CKEditor profile > Advanced options > Custom JavaScript configuration

config.ckeditor_image2_initial_width = 300;
config.ckeditor_image2_initial_height = 300;

It replaces the original image2 change event function but calls it anyway. I couldn't figure out how to chain the events so I used a setTimeout().

bwaindwain’s picture

here's a better patch that doesn't use a timeout

jwilson3’s picture

If you're using the responsive css provided with this module, you don't need to set an initial size because the size is scaled automatically to the width of the embedded ckeditor field on the backend, and to the width of the body field in the content column on the front-end.

Furthermore, the Drupal 8 version of this feature doesn't do anything like this either. So I dont think it makes sense to introduce a new feature that doesn't have parity with Drupal 8 at this point.

It looks like you've achieved what you need with this patch, and thanks for providing it to the community but I'm not convinced this is something that this module should be responsible for doing.

jwilson3’s picture

Status: Needs review » Closed (works as designed)