title: How to populate tinyMCE image upload popup fields after selecting image
body: <p>First to mention I am stuck in <strong>tinyMCE</strong> version <code>4.0.20</code> (For some stability issue I am not able to update the version in my project)</p>
  
  <p>I have initiated tinyMCE editor and all necessary plugins. I need to have a image upload feature here (actually embed the image as <em>data image</em>). In that purpose what I have done the code so far would be found in this <a href="https://jsfiddle.net/1fn4bkug/2/" rel="nofollow noreferrer">jsfiddle</a></p>
  
  <p>Following is the <code>file_browser_callback</code> so far I have written.</p>
  
  <pre><code>function (field_name, url, type, window) {
     var input = document.createElement('input');
     input.setAttribute('type', 'file');
     input.setAttribute('accept', 'image/*');
  
     input.onchange = function () {
          var file = this.files[0];
          var reader = new FileReader();
  
          reader.onload = function () {
          var base64 = reader.result;
  
          var image = new Image();
          image.src = base64;
          image.alt = file.name;
  
          image.onload = function () {
            /*
             * just to work around I tried below to populate the fields.
             * but for putting dimesions, I dont know how to do that. I
             * think there should be some function or something in tinyMCE
             * for that purpose
             */
                 window.document.getElementById(field_name).value = image.src;
                 $('input.mce-last', window.document).val(image.alt);
            }
  
          };
  
          reader.readAsDataURL(file);
    };
  
    input.click();
  }
  </code></pre>
  
  <p>I want to populate the popup fields with image <strong>title</strong>, <strong>description</strong> and <strong>dimensions</strong> from the image meta data. And you will notice there is a <em>checkbox</em> beside <em>dimensions</em> field <em>Contains proportion</em> that should work for <em>maintain proportion</em> from <strong>tinyMCE</strong></p>
  
  <p>I think the following image can help you understand.</p>
  
  <p><a href="https://i.stack.imgur.com/gEMnd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gEMnd.png" alt="enter image description here"></a></p>
  
  <p>Any help would be appreciated.</p>