0

I'm using the Image_Widget_Crop module for a Drupal 8 website. In this module there is a .js file setting the default values for Cropper.

Drupal.ImageWidgetCropType.prototype.defaultOptions = {
    autoCropArea: 1,
    background: false,
    responsive: false,
    viewMode: 1,
    zoomable: false
  };

I want to add a setting without putting it in the module so when updating my change doesn't get lost, how can I do this?

I want it to look like this.

Drupal.ImageWidgetCropType.prototype.defaultOptions = {
    autoCropArea: 1,
    background: false,
    responsive: false,
    viewMode: 1,
    zoomable: false,
    toggleDragModeOnDblclick: false
  };

1 Answer 1

2

Add your own library with a JS file, make sure the file has a weight higher than the image widget crop's JS file, then simply monkey patch the existing object like so:

Drupal.ImageWidgetCropType.prototype.defaultOptions.toggleDragModeOnDblclick = false;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.