raj
raj

Reputation: 281

How to set additional field value while editing the image in ckeditor image dialog

My task is, whatever images added in the ckeditor through image dialog it should be responsive.

To achieve this:

  1. I have introduced new option 'srcset' in advanced tab
  2. Removed the property width and height from style option
  3. Set max-width property in style option

It's working fine.

Now the issue is, if we right-click the added image in ckeditor then context-menu will open with the following options 'cut, copy, paste and image properties'. In this, if we choose 'image property' then the image dialog will open and in dialog advanced tab, srcset option set to empty but I gave the srcset value while adding a image.

How to fix this issue?

Upvotes: 0

Views: 147

Answers (1)

raj
raj

Reputation: 281

Solution:

dialogDefinition.dialog.on('show', function (event) {
                if (event.sender.getSelectedElement()) {
                    var srcset = event.sender.getSelectedElement().getAttribute('srcset');
                    dialogDefinition.dialog.setValueOf('advanced', 'txtdlgGenSrcSet', srcset);
                }
            });

'txtdlgGenSrcSet' is new option.

Upvotes: 2

Related Questions