title: How to get <img> content-type using javascript after loading
body: <p>In my HTML document, there is a image</p>
  
  <pre><code>&lt;img src="https://www.gravatar.com/avatar/1d9c87a4d5cbcae4c76e867cb6861fa0?s=48&amp;d=identicon&amp;r=PG&amp;f=1"/&gt;
  </code></pre>
  
  <p>When open this document in browser, E.g. Chrome, we can find the <code>Content-Type</code> of this image is <code>"image/png"</code> in Chrome Developer Tools -> Network tab according to the HTTP response headers.</p>
  
  <p>How can I get the <code>Content-Type</code> using JavaScript after the image loading. </p>
  
  <p>More specifically, what I need is a function like below.</p>
  
  <pre><code>/**
   * @param  {HTMLImageElement} img
   * @return {String}     the content type, e.g. "image/png", "image/svg+xml"
   */
  getImgContentType(img) {
      // TODO
  }
  </code></pre>