Skip to content Skip to sidebar Skip to footer

Tinymce Get Image _description With File_picker_callback And Image Uploader

TL:DR I am trying to get the value of image_description field using javascript to past it my post xhr request Original question below I am using file_picker_callback type image htt

Solution 1:

Try this to get value:

images_upload_handler: function (blobInfo, success, failure) {
      var xhr, formData;

      xhr = newXMLHttpRequest();
      xhr.withCredentials = false;
      xhr.open('POST', '/articles/postAcceptor');

      xhr.onload = function() {
        var json;

        if (xhr.status != 200) {
          failure('HTTP Error: ' + xhr.status);
          return;
        }

        json = JSON.parse(xhr.responseText);

        if (!json || typeof json.location != 'string') {
          failure('Invalid JSON: ' + xhr.responseText);
          return;
        }

        success(json.location);
      };


      var description = '';

      jQuery(tinymce.activeEditor.dom.getRoot()).find('img').not('.loaded-before').each(
    function() {
        description = $(this).attr("alt");
        $(this).addClass('loaded-before');
    });

      formData = newFormData();
      formData.append('file', blobInfo.blob(), blobInfo.filename());
      formData.append('description', description); //found now))

      xhr.send(formData);
    }

Solution 2:

The following may be will help you https://www.tinymce.com

<!DOCTYPE html><html><head><scriptsrc="https://cloud.tinymce.com/stable/tinymce.min.js"></script><script>tinymce.init({ selector:'textarea' });</script></head><body><textarea>Next, get a free TinyMCE Cloud API key!</textarea></body></html>

Post a Comment for "Tinymce Get Image _description With File_picker_callback And Image Uploader"