From e57bf3186ee23fbfd266ae360ef592d20ddcf769 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 22 Mar 2013 14:43:44 +0100 Subject: [PATCH] Aspect ratio corrective --- templates/web/prod/actions/Tools/index.html.twig | 2 +- www/prod/ThumbExtractor.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/web/prod/actions/Tools/index.html.twig b/templates/web/prod/actions/Tools/index.html.twig index 596b970eda..4778e3430e 100644 --- a/templates/web/prod/actions/Tools/index.html.twig +++ b/templates/web/prod/actions/Tools/index.html.twig @@ -131,7 +131,7 @@ {% set height = record.get_technical_infos(dataH) %} {% if width and height %} - {% set ratio = width / height %} + {% set ratio = (width / height)|number_format(2, '.') %} {% else %} {% set ratio = '' %} {% endif %} diff --git a/www/prod/ThumbExtractor.js b/www/prod/ThumbExtractor.js index c4bbd77c3b..b235aa51cd 100644 --- a/www/prod/ThumbExtractor.js +++ b/www/prod/ThumbExtractor.js @@ -14,11 +14,13 @@ var maxH = elementDomNode.getHeight(); if ('' !== elementDomNode.getAspectRatio()) { - var h = Math.round(w * (1 / elementDomNode.getAspectRatio())); + var ratio = parseFloat(elementDomNode.getAspectRatio()); + + var h = Math.round(w * (1 / ratio)); if (h > maxH) { var h = maxH; - var w = Math.round(h * elementDomNode.getAspectRatio()); + var w = Math.round(h * ratio); } } else { var h = maxH;