mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 04:53:26 +00:00
Fix #1041 Keep video aspect ratio when extracting thumbnail using canva
This commit is contained in:
@@ -124,7 +124,19 @@
|
|||||||
<div class="PNB frame_video">
|
<div class="PNB frame_video">
|
||||||
|
|
||||||
{% set previewHtml5 = record.getSubdfefByDeviceAndMime(constant('\\databox_subdef::DEVICE_SCREEN'), ['video/ogg', 'video/mp4', 'video/webm']) %}
|
{% set previewHtml5 = record.getSubdfefByDeviceAndMime(constant('\\databox_subdef::DEVICE_SCREEN'), ['video/ogg', 'video/mp4', 'video/webm']) %}
|
||||||
<video id="thumb_video" controls="" preload="auto">
|
{% set dataW = constant('media_subdef::TC_DATA_WIDTH') %}
|
||||||
|
{% set dataH = constant('media_subdef::TC_DATA_HEIGHT') %}
|
||||||
|
|
||||||
|
{% set width = record.get_technical_infos(dataW) %}
|
||||||
|
{% set height = record.get_technical_infos(dataH) %}
|
||||||
|
|
||||||
|
{% if width and height %}
|
||||||
|
{% set ratio = (width / height) %}
|
||||||
|
{% else %}
|
||||||
|
{% set ratio = 1 %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<video id="thumb_video" controls="" preload="auto" data-ratio="{{ ratio }}">
|
||||||
{% for subdef in previewHtml5 %}
|
{% for subdef in previewHtml5 %}
|
||||||
<source type="{{ subdef.get_mime() }}" src="{{ subdef.get_url() }}" />
|
<source type="{{ subdef.get_mime() }}" src="{{ subdef.get_url() }}" />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@@ -6,12 +6,20 @@
|
|||||||
*****************/
|
*****************/
|
||||||
var Canva = function(domCanva){
|
var Canva = function(domCanva){
|
||||||
this.domCanva = domCanva;
|
this.domCanva = domCanva;
|
||||||
}
|
};
|
||||||
|
|
||||||
Canva.prototype = {
|
Canva.prototype = {
|
||||||
resize : function(elementDomNode){
|
resize : function(elementDomNode){
|
||||||
var h = elementDomNode.getHeight();
|
|
||||||
var w = elementDomNode.getWidth();
|
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("width", w);
|
||||||
this.domCanva.setAttribute("height", h);
|
this.domCanva.setAttribute("height", h);
|
||||||
@@ -20,7 +28,7 @@
|
|||||||
},
|
},
|
||||||
getContext2d : function(){
|
getContext2d : function(){
|
||||||
|
|
||||||
if (this.domCanva.getContext == undefined)
|
if (this.domCanva.getContext === undefined)
|
||||||
{
|
{
|
||||||
return G_vmlCanvasManager
|
return G_vmlCanvasManager
|
||||||
.initElement(this.domCanva)
|
.initElement(this.domCanva)
|
||||||
@@ -94,6 +102,7 @@
|
|||||||
|
|
||||||
var Video = function(domElement){
|
var Video = function(domElement){
|
||||||
Image.call(this, domElement);
|
Image.call(this, domElement);
|
||||||
|
this.aspectRatio = domElement.getAttribute('data-ratio') || 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
Video.prototype = new Image();
|
Video.prototype = new Image();
|
||||||
@@ -101,6 +110,9 @@
|
|||||||
Video.prototype.getCurrentTime = function(){
|
Video.prototype.getCurrentTime = function(){
|
||||||
return Math.floor(this.domElement.currentTime);
|
return Math.floor(this.domElement.currentTime);
|
||||||
};
|
};
|
||||||
|
Video.prototype.getAspectRatio = function(){
|
||||||
|
return this.aspectRatio;
|
||||||
|
};
|
||||||
|
|
||||||
/******************
|
/******************
|
||||||
* Cache Object
|
* Cache Object
|
||||||
@@ -148,7 +160,7 @@
|
|||||||
this.timestamp = date.getTime();
|
this.timestamp = date.getTime();
|
||||||
this.dataURI = canva.extractImage();
|
this.dataURI = canva.extractImage();
|
||||||
this.videoTime = video.getCurrentTime();
|
this.videoTime = video.getCurrentTime();
|
||||||
}
|
};
|
||||||
|
|
||||||
ScreenShot.prototype = {
|
ScreenShot.prototype = {
|
||||||
getId:function(){
|
getId:function(){
|
||||||
|
@@ -3732,7 +3732,7 @@ dans l'onglet thesaurus : arbres, menus contextuels
|
|||||||
#thumbExtractor .main_title {
|
#thumbExtractor .main_title {
|
||||||
height: 15px;
|
height: 15px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
top: 15px
|
top: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#thumbExtractor .part_title_left {
|
#thumbExtractor .part_title_left {
|
||||||
@@ -3771,11 +3771,18 @@ dans l'onglet thesaurus : arbres, menus contextuels
|
|||||||
border: 1px solid #1A1B1B;
|
border: 1px solid #1A1B1B;
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
height: 210px;
|
height: 210px;
|
||||||
|
line-height:210px;
|
||||||
width: 320px;
|
width: 320px;
|
||||||
top: 50px;
|
top: 50px;
|
||||||
left: 380px;
|
left: 380px;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
text-align: center
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#thumbExtractor #thumb_canvas {
|
||||||
|
vertical-align:middle;
|
||||||
|
display:inline-block;
|
||||||
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#thumbExtractor .action_bar_left {
|
#thumbExtractor .action_bar_left {
|
||||||
@@ -3802,7 +3809,7 @@ dans l'onglet thesaurus : arbres, menus contextuels
|
|||||||
#thumbExtractor .action_bar_right .action_icon {
|
#thumbExtractor .action_bar_right .action_icon {
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
vertical-align: middle
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
#thumbExtractor .action_bar_right .action_icon:hover {
|
#thumbExtractor .action_bar_right .action_icon:hover {
|
||||||
@@ -3816,6 +3823,7 @@ dans l'onglet thesaurus : arbres, menus contextuels
|
|||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
right: 60px;
|
right: 60px;
|
||||||
display: none;
|
display: none;
|
||||||
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#thumbExtractor #thumb_delete_button {
|
#thumbExtractor #thumb_delete_button {
|
||||||
@@ -3824,7 +3832,8 @@ dans l'onglet thesaurus : arbres, menus contextuels
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
display: none
|
display: none;
|
||||||
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#thumbExtractor #thumb_delete_button,
|
#thumbExtractor #thumb_delete_button,
|
||||||
|
@@ -3915,6 +3915,7 @@ dans l'onglet thesaurus : arbres, menus contextuels
|
|||||||
border: 1px solid #1A1B1B;
|
border: 1px solid #1A1B1B;
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
height: 210px;
|
height: 210px;
|
||||||
|
line-height:210px;
|
||||||
width: 320px;
|
width: 320px;
|
||||||
top: 50px;
|
top: 50px;
|
||||||
left: 380px;
|
left: 380px;
|
||||||
@@ -3922,6 +3923,12 @@ dans l'onglet thesaurus : arbres, menus contextuels
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#thumbExtractor #thumb_canvas {
|
||||||
|
vertical-align:middle;
|
||||||
|
display:inline-block;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
#thumbExtractor .action_bar_left {
|
#thumbExtractor .action_bar_left {
|
||||||
height: 20px;
|
height: 20px;
|
||||||
width: 320px;
|
width: 320px;
|
||||||
@@ -3960,6 +3967,7 @@ dans l'onglet thesaurus : arbres, menus contextuels
|
|||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
right: 60px;
|
right: 60px;
|
||||||
display: none;
|
display: none;
|
||||||
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#thumbExtractor #thumb_delete_button {
|
#thumbExtractor #thumb_delete_button {
|
||||||
@@ -3969,6 +3977,7 @@ dans l'onglet thesaurus : arbres, menus contextuels
|
|||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
display: none;
|
display: none;
|
||||||
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#thumbExtractor #thumb_delete_button,
|
#thumbExtractor #thumb_delete_button,
|
||||||
|
Reference in New Issue
Block a user