mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Fix #1041 Keep video aspect ratio when extracting thumbnail using canva
This commit is contained in:
@@ -6,12 +6,20 @@
|
||||
*****************/
|
||||
var Canva = function(domCanva){
|
||||
this.domCanva = domCanva;
|
||||
}
|
||||
};
|
||||
|
||||
Canva.prototype = {
|
||||
resize : function(elementDomNode){
|
||||
var h = elementDomNode.getHeight();
|
||||
var w = elementDomNode.getWidth();
|
||||
var maxH = elementDomNode.getHeight();
|
||||
|
||||
var h = Math.round(w * (1 / elementDomNode.getAspectRatio()));
|
||||
|
||||
if (h > maxH) {
|
||||
var h = maxH;
|
||||
var w = Math.round(h * elementDomNode.getAspectRatio());
|
||||
}
|
||||
|
||||
|
||||
this.domCanva.setAttribute("width", w);
|
||||
this.domCanva.setAttribute("height", h);
|
||||
@@ -20,7 +28,7 @@
|
||||
},
|
||||
getContext2d : function(){
|
||||
|
||||
if (this.domCanva.getContext == undefined)
|
||||
if (this.domCanva.getContext === undefined)
|
||||
{
|
||||
return G_vmlCanvasManager
|
||||
.initElement(this.domCanva)
|
||||
@@ -94,6 +102,7 @@
|
||||
|
||||
var Video = function(domElement){
|
||||
Image.call(this, domElement);
|
||||
this.aspectRatio = domElement.getAttribute('data-ratio') || 1;
|
||||
};
|
||||
|
||||
Video.prototype = new Image();
|
||||
@@ -101,6 +110,9 @@
|
||||
Video.prototype.getCurrentTime = function(){
|
||||
return Math.floor(this.domElement.currentTime);
|
||||
};
|
||||
Video.prototype.getAspectRatio = function(){
|
||||
return this.aspectRatio;
|
||||
};
|
||||
|
||||
/******************
|
||||
* Cache Object
|
||||
@@ -148,7 +160,7 @@
|
||||
this.timestamp = date.getTime();
|
||||
this.dataURI = canva.extractImage();
|
||||
this.videoTime = video.getCurrentTime();
|
||||
}
|
||||
};
|
||||
|
||||
ScreenShot.prototype = {
|
||||
getId:function(){
|
||||
|
Reference in New Issue
Block a user