Remove ratio = 1 as default

This commit is contained in:
Nicolas Le Goff
2013-03-21 12:46:00 +01:00
parent ae78df11af
commit 3dc3caf137
2 changed files with 10 additions and 7 deletions

View File

@@ -131,9 +131,9 @@
{% set height = record.get_technical_infos(dataH) %} {% set height = record.get_technical_infos(dataH) %}
{% if width and height %} {% if width and height %}
{% set ratio = (width / height) %} {% set ratio = width / height %}
{% else %} {% else %}
{% set ratio = 1 %} {% set ratio = '' %}
{% endif %} {% endif %}
<video id="thumb_video" controls="" preload="auto" data-ratio="{{ ratio }}"> <video id="thumb_video" controls="" preload="auto" data-ratio="{{ ratio }}">

View File

@@ -13,14 +13,17 @@
var w = elementDomNode.getWidth(); var w = elementDomNode.getWidth();
var maxH = elementDomNode.getHeight(); var maxH = elementDomNode.getHeight();
var h = Math.round(w * (1 / elementDomNode.getAspectRatio())); if ('' !== elementDomNode.getAspectRatio()) {
var h = Math.round(w * (1 / elementDomNode.getAspectRatio()));
if (h > maxH) { if (h > maxH) {
var h = maxH;
var w = Math.round(h * elementDomNode.getAspectRatio());
}
} else {
var h = maxH; var h = maxH;
var w = Math.round(h * elementDomNode.getAspectRatio());
} }
this.domCanva.setAttribute("width", w); this.domCanva.setAttribute("width", w);
this.domCanva.setAttribute("height", h); this.domCanva.setAttribute("height", h);
@@ -102,7 +105,7 @@
var Video = function(domElement){ var Video = function(domElement){
Image.call(this, domElement); Image.call(this, domElement);
this.aspectRatio = domElement.getAttribute('data-ratio') || 1; this.aspectRatio = domElement.getAttribute('data-ratio');
}; };
Video.prototype = new Image(); Video.prototype = new Image();