diff --git a/js/load-image-fetch.js b/js/load-image-fetch.js index 9ca1ccd..6778fea 100644 --- a/js/load-image-fetch.js +++ b/js/load-image-fetch.js @@ -25,7 +25,7 @@ }(function (loadImage) { 'use strict' - if ('fetch' in window && 'Request' in window) { + if (typeof fetch !== 'undefined' && typeof Request !== 'undefined') { loadImage.fetchBlob = function (url, callback, options) { if (loadImage.hasMetaOption(options)) { return fetch(new Request(url, options)).then(function (response) { diff --git a/js/load-image-meta.js b/js/load-image-meta.js index fc76958..3abd119 100644 --- a/js/load-image-meta.js +++ b/js/load-image-meta.js @@ -29,7 +29,7 @@ }(function (loadImage) { 'use strict' - var hasblobSlice = window.Blob && (Blob.prototype.slice || + var hasblobSlice = typeof Blob !== 'undefined' && (Blob.prototype.slice || Blob.prototype.webkitSlice || Blob.prototype.mozSlice) loadImage.blobSlice = hasblobSlice && function () { @@ -55,7 +55,7 @@ var that = this // 256 KiB should contain all EXIF/ICC/IPTC segments: var maxMetaDataSize = options.maxMetaDataSize || 262144 - var noMetaData = !(window.DataView && file && file.size >= 12 && + var noMetaData = !(typeof DataView !== 'undefined' && file && file.size >= 12 && file.type === 'image/jpeg' && loadImage.blobSlice) if (noMetaData || !loadImage.readFile( loadImage.blobSlice.call(file, 0, maxMetaDataSize), diff --git a/js/load-image.js b/js/load-image.js index 3d3ac94..c95330a 100644 --- a/js/load-image.js +++ b/js/load-image.js @@ -61,9 +61,9 @@ } // The check for URL.revokeObjectURL fixes an issue with Opera 12, // which provides URL.createObjectURL but doesn't properly implement it: - var urlAPI = (window.createObjectURL && window) || - (window.URL && URL.revokeObjectURL && URL) || - (window.webkitURL && webkitURL) + var urlAPI = ($.createObjectURL && $) || + ($.URL && URL.revokeObjectURL && URL) || + ($.webkitURL && webkitURL) function revokeHelper (img, options) { if (img._objectURL && !(options && options.noRevoke)) { @@ -135,4 +135,4 @@ } else { $.loadImage = loadImage } -}(window)) +}(this))