This is a migrated thread and some comments may be shown as answers.

Require Image Browser Alternate Text

1 Answer 127 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 06 Sep 2017, 08:13 PM
Is there a way to make the "Alternate Text" value required for the Image Browser.  I have found a way to implement this functionality for the Insert button, but I cannot find a way for it to work for double-clicking the image.  Note, I do consider the Insert button "solution" a hack and would prefer to implement a better solution if one exists.

// Editor definition
element.kendoEditor({
  execute: handlers_editorExecute,
  imageBrowser: {
    apply: handlers_editorImageBrowserApply,
  }
});
     
// This does not work for double-clicking the image because the image is inserted regardless of the return value
handlers_editorImageBrowserApply: function (e) {
  var imageBrowser = $(".k-imagebrowser").data("kendoImageBrowser"); 
 
  if (imageBrowser.value() != "") {
    if ($(".k-filebrowser-dialog #k-editor-image-title").val() == "") {
      alert("Alternate text is required.");
      return false;
    }
  }
},
// This does work for clicking the Insert button and the apply function is not defined, but feels like a hack
handlers_editorExecute: function (e) {
  if (e.name == "insertimage") {
    setTimeout(function () {
      var insertButton = $(".k-filebrowser-dialog .k-dialog-insert");
      insertButton.unbind("click");
      insertButton.click(function () {
        var imageBrowser = $(".k-imagebrowser").data("kendoImageBrowser");
        if (imageBrowser.value() != "") {
          if ($(".k-filebrowser-dialog #k-editor-image-title").val() == "") {
            alert("Alternate text is required.");
            return false;
          }
        }
        imageBrowser.trigger("apply");
      });
    });
  }
},

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 08 Sep 2017, 12:42 PM

Hello Christopher,

I am afraid there is no more suitable solution for the case. The code you have implemented seems to work properly as per to this requirement. 

What I can suggest you is to post a feedback item in the Kendo feedback portal and request the FileBrowser and ImageBrowser to be refactored so that they are more flexible and customizable. Or just request an option for the alt text to be made required. 

Regards,
Ianko
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Editor
Asked by
Christopher
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or