From 05e7b8021d17772f3fb0db4667b7901b1c34a474 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 9 Mar 2015 16:46:02 +0200 Subject: client/graph_view: set maximal size of 100px for an image, keeping aspect ratio --- src/client/view/graph_view.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index e2b7520e..d4cfb145 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -482,8 +482,11 @@ function GraphView(spec) { var element = this, image = new Image(); image.onload = function () { - element.setAttribute("width", this.width); - element.setAttribute("height", this.height); + var aspect = this.height / this.width, + width = Math.min(100, this.width); + + element.setAttribute("width", width); + element.setAttribute("height", Math.min(width * aspect, this.height)); element.setAttributeNS("http://www.w3.org/1999/xlink", "href", this.src); } image.src = urlImage(d) ? d.url : "/static/img/url-icon.png"; -- cgit v1.3.1