Commit 4a1eac06 authored by JC Brand's avatar JC Brand

Check if canvas is supported before trying to render the user avatar.

parent 490d96fd
...@@ -5,6 +5,7 @@ Changelog ...@@ -5,6 +5,7 @@ Changelog
------------------ ------------------
* Don't load OTR crypto if the browser doesn't have a CSRNG [jcbrand] * Don't load OTR crypto if the browser doesn't have a CSRNG [jcbrand]
* Check if canvas is supported before trying to render the user avatar [jcbrand]
0.7.0 (2013-11-13) 0.7.0 (2013-11-13)
------------------ ------------------
......
...@@ -1207,9 +1207,13 @@ ...@@ -1207,9 +1207,13 @@
return; return;
} }
var img_src = 'data:'+this.model.get('image_type')+';base64,'+this.model.get('image'), var img_src = 'data:'+this.model.get('image_type')+';base64,'+this.model.get('image'),
canvas = $('<canvas height="33px" width="33px" class="avatar"></canvas>'), canvas = $('<canvas height="33px" width="33px" class="avatar"></canvas>').get(0);
ctx = canvas.get(0).getContext('2d'),
img = new Image(); // Create new Image object if (!(canvas.getContext && canvas.getContext('2d'))) {
return this;
}
var ctx = canvas.getContext('2d');
var img = new Image(); // Create new Image object
img.onload = function() { img.onload = function() {
var ratio = img.width/img.height; var ratio = img.width/img.height;
ctx.drawImage(img, 0,0, 35*ratio, 35); ctx.drawImage(img, 0,0, 35*ratio, 35);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment