|
28 | 28 | var img = document.createElement('img')
|
29 | 29 | var url
|
30 | 30 | img.onerror = function (event) {
|
31 |
| - return loadImage.onerror(img, event, file, callback, options) |
| 31 | + return loadImage.onerror(img, event, file, url, callback, options) |
32 | 32 | }
|
33 | 33 | img.onload = function (event) {
|
34 |
| - return loadImage.onload(img, event, file, callback, options) |
| 34 | + return loadImage.onload(img, event, file, url, callback, options) |
35 | 35 | }
|
36 | 36 | if (typeof file === 'string') {
|
37 | 37 | loadImage.fetchBlob(
|
|
58 | 58 | // (Firefox 3.6) support the File API but not Blobs:
|
59 | 59 | loadImage.isInstanceOf('File', file)
|
60 | 60 | ) {
|
61 |
| - url = img._objectURL = loadImage.createObjectURL(file) |
| 61 | + url = loadImage.createObjectURL(file) |
62 | 62 | if (url) {
|
63 | 63 | img.src = url
|
64 | 64 | return img
|
|
83 | 83 | /**
|
84 | 84 | * Helper function to revoke an object URL
|
85 | 85 | *
|
86 |
| - * @param {HTMLImageElement} img Image element |
| 86 | + * @param {string} url Blob Object URL |
87 | 87 | * @param {object} [options] Options object
|
88 | 88 | */
|
89 |
| - function revokeHelper(img, options) { |
90 |
| - if (img._objectURL && !(options && options.noRevoke)) { |
91 |
| - loadImage.revokeObjectURL(img._objectURL) |
92 |
| - delete img._objectURL |
| 89 | + function revokeHelper(url, options) { |
| 90 | + if (url && url.slice(0, 5) === 'blob:' && !(options && options.noRevoke)) { |
| 91 | + loadImage.revokeObjectURL(url) |
93 | 92 | }
|
94 | 93 | }
|
95 | 94 |
|
|
109 | 108 | callback(img, data)
|
110 | 109 | }
|
111 | 110 |
|
112 |
| - loadImage.onerror = function (img, event, file, callback, options) { |
113 |
| - revokeHelper(img, options) |
| 111 | + loadImage.onerror = function (img, event, file, url, callback, options) { |
| 112 | + revokeHelper(url, options) |
114 | 113 | if (callback) {
|
115 | 114 | callback.call(img, event)
|
116 | 115 | }
|
117 | 116 | }
|
118 | 117 |
|
119 |
| - loadImage.onload = function (img, event, file, callback, options) { |
120 |
| - revokeHelper(img, options) |
| 118 | + loadImage.onload = function (img, event, file, url, callback, options) { |
| 119 | + revokeHelper(url, options) |
121 | 120 | if (callback) {
|
122 | 121 | loadImage.transform(img, options, callback, file, {
|
123 | 122 | originalWidth: img.naturalWidth || img.width,
|
|
0 commit comments