dist/viewer.common.js
function getImageNaturalSizes(image, callback) {
  var newImage = document.createElement('img');

  // Modern browsers (except Safari)
  if (image.naturalWidth && !IS_SAFARI) {
    callback(image.naturalWidth, image.naturalHeight);
    return newImage;
  }

  var body = document.body || document.documentElement;

  newImage.onload = function () {
    callback(newImage.width, newImage.height);

    if (!IS_SAFARI) {
      body.removeChild(newImage);
    }
  };

  newImage.src = image.src;

  // iOS Safari will convert the image automatically
  // with its orientation once append it into DOM
  if (!IS_SAFARI) {
    newImage.style.cssText = 'left:0;' + 'max-height:none!important;' + 'max-width:none!important;' + 'min-height:0!important;' + 'min-width:0!important;' + 'opacity:0;' + 'position:absolute;' + 'top:0;' + 'z-index:-1;';
    body.appendChild(newImage);
  }

  return newImage;
}
function getImageNaturalSizes(image, callback) {
  var newImage = document.createElement('img');

  // Modern browsers (except Safari)
  if (image.naturalWidth && !IS_SAFARI) {
    callback(image.naturalWidth, image.naturalHeight);
    return newImage;
  }

  var body = document.body || document.documentElement;

  newImage.onload = function () {
    callback(newImage.width, newImage.height);

    if (!IS_SAFARI) {
      body.removeChild(newImage);
    }
  };

  newImage.src = image.src;

  // iOS Safari will convert the image automatically
  // with its orientation once append it into DOM
  if (!IS_SAFARI) {
    newImage.style.cssText = 'left:0;' + 'max-height:none!important;' + 'max-width:none!important;' + 'min-height:0!important;' + 'min-width:0!important;' + 'opacity:0;' + 'position:absolute;' + 'top:0;' + 'z-index:-1;';
    body.appendChild(newImage);
  }

  return newImage;
}
function getImageNaturalSizes ( image , callback ) { var newImage = document . createElement ( 'img' ) ; // Modern browsers (except Safari) if ( image . naturalWidth && ! IS_SAFARI ) { callback ( image . naturalWidth , image . naturalHeight ) ; return newImage ; } var body = document . body || document . documentElement ; newImage . onload = function ( ) { callback ( newImage . width , newImage . height ) ; if ( ! IS_SAFARI ) { body . removeChild ( newImage ) ; } } ; newImage . src = image . src ; // iOS Safari will convert the image automatically // with its orientation once append it into DOM if ( ! IS_SAFARI ) { newImage . style . cssText = 'left:0;' + 'max-height:none!important;' + 'max-width:none!important;' + 'min-height:0!important;' + 'min-width:0!important;' + 'opacity:0;' + 'position:absolute;' + 'top:0;' + 'z-index:-1;' ; body . appendChild ( newImage ) ; } return newImage ; }
Get an image's natural sizes.
@param {string} image - The target image.
@param {Function} callback - The callback function.
@returns {HTMLImageElement} The new image.
Get an image s natural sizes .