|
107 | 107 | img.src = url |
108 | 108 | } |
109 | 109 | img.onerror = function (event) { |
110 | | - return loadImage.onerror(img, event, file, url, reject, options) |
| 110 | + revokeHelper(url, options) |
| 111 | + if (reject) reject.call(img, event) |
111 | 112 | } |
112 | | - img.onload = function (event) { |
113 | | - return loadImage.onload(img, event, file, url, resolveWrapper, options) |
| 113 | + img.onload = function () { |
| 114 | + revokeHelper(url, options) |
| 115 | + var data = { |
| 116 | + originalWidth: img.naturalWidth || img.width, |
| 117 | + originalHeight: img.naturalHeight || img.height |
| 118 | + } |
| 119 | + try { |
| 120 | + loadImage.transform(img, options, resolveWrapper, file, data) |
| 121 | + } catch (error) { |
| 122 | + if (reject) reject(error) |
| 123 | + } |
114 | 124 | } |
115 | 125 | if (typeof file === 'string') { |
116 | 126 | if (loadImage.requiresMetaData(options)) { |
|
169 | 179 | callback(img, data) |
170 | 180 | } |
171 | 181 |
|
172 | | - loadImage.onerror = function (img, event, file, url, callback, options) { |
173 | | - revokeHelper(url, options) |
174 | | - if (callback) { |
175 | | - callback.call(img, event) |
176 | | - } |
177 | | - } |
178 | | - |
179 | | - loadImage.onload = function (img, event, file, url, callback, options) { |
180 | | - revokeHelper(url, options) |
181 | | - |
182 | | - try { |
183 | | - loadImage.transform(img, options, callback, file, { |
184 | | - originalWidth: img.naturalWidth || img.width, |
185 | | - originalHeight: img.naturalHeight || img.height |
186 | | - }) |
187 | | - } catch (error) { |
188 | | - callback(error) |
189 | | - } |
190 | | - } |
191 | | - |
192 | 182 | // Loads a given File object via FileReader interface, |
193 | 183 | // invokes the callback with the event object (load or error). |
194 | 184 | // The result can be read via event.target.result: |
|
0 commit comments