mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-22 12:04:58 -05:00
Safari needs the img.onload event before actually working on the img
This commit is contained in:
parent
be2f948da5
commit
c8d0c4762d
@ -82,6 +82,7 @@ angular.module('mFileUpload', ['matrixService', 'mUtilities'])
|
|||||||
// First, get the image size
|
// First, get the image size
|
||||||
mUtilities.getImageSize(imageFile).then(
|
mUtilities.getImageSize(imageFile).then(
|
||||||
function(size) {
|
function(size) {
|
||||||
|
console.log("image size: " + JSON.stringify(size));
|
||||||
|
|
||||||
// The final operation: send imageFile
|
// The final operation: send imageFile
|
||||||
var uploadImage = function() {
|
var uploadImage = function() {
|
||||||
|
@ -38,11 +38,16 @@ angular.module('mUtilities', [])
|
|||||||
img.src = e.target.result;
|
img.src = e.target.result;
|
||||||
|
|
||||||
// Once ready, returns its size
|
// Once ready, returns its size
|
||||||
|
img.onload = function() {
|
||||||
deferred.resolve({
|
deferred.resolve({
|
||||||
width: img.width,
|
width: img.width,
|
||||||
height: img.height
|
height: img.height
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
img.onerror = function(e) {
|
||||||
|
deferred.reject(e);
|
||||||
|
};
|
||||||
|
};
|
||||||
reader.onerror = function(e) {
|
reader.onerror = function(e) {
|
||||||
deferred.reject(e);
|
deferred.reject(e);
|
||||||
};
|
};
|
||||||
@ -72,6 +77,8 @@ angular.module('mUtilities', [])
|
|||||||
|
|
||||||
img.src = e.target.result;
|
img.src = e.target.result;
|
||||||
|
|
||||||
|
// Once ready, returns its size
|
||||||
|
img.onload = function() {
|
||||||
var ctx = canvas.getContext("2d");
|
var ctx = canvas.getContext("2d");
|
||||||
ctx.drawImage(img, 0, 0);
|
ctx.drawImage(img, 0, 0);
|
||||||
|
|
||||||
@ -99,6 +106,10 @@ angular.module('mUtilities', [])
|
|||||||
var dataUrl = canvas.toDataURL("image/jpeg", 0.7);
|
var dataUrl = canvas.toDataURL("image/jpeg", 0.7);
|
||||||
deferred.resolve(self.dataURItoBlob(dataUrl));
|
deferred.resolve(self.dataURItoBlob(dataUrl));
|
||||||
};
|
};
|
||||||
|
img.onerror = function(e) {
|
||||||
|
deferred.reject(e);
|
||||||
|
};
|
||||||
|
};
|
||||||
reader.onerror = function(e) {
|
reader.onerror = function(e) {
|
||||||
deferred.reject(e);
|
deferred.reject(e);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user