mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Fix division by 0 in case a thumbnail has a width or height equal to 0
This commit is contained in:
@@ -3,23 +3,27 @@
|
||||
{% set b_height = b_h|default(b_w) %}
|
||||
|
||||
{% set b_ratio = b_width / b_height %}
|
||||
{% set i_ratio = thumbnail.get_width() / thumbnail.get_height() %}
|
||||
|
||||
{% set thumbnail_height = thumbnail.get_height() > 0 ? thumbnail.get_height() : 120 %}
|
||||
{% set thumbnail_width = thumbnail.get_width() > 0 ? thumbnail.get_width() : 120 %}
|
||||
|
||||
{% set i_ratio = thumbnail_width / thumbnail_height %}
|
||||
|
||||
{% if i_ratio > b_ratio%}
|
||||
{% if b_width > thumbnail.get_width() %}
|
||||
{% set d_width = thumbnail.get_width() %}
|
||||
{% if b_width > thumbnail_width %}
|
||||
{% set d_width = thumbnail_width %}
|
||||
{% else %}
|
||||
{% set d_width = b_width %}
|
||||
{% endif %}
|
||||
{% set d_height = d_width / thumbnail.get_width() * thumbnail.get_height() %}
|
||||
{% set d_height = d_width / thumbnail_width * thumbnail_height %}
|
||||
{% set top = (b_height - d_height) / 2 %}
|
||||
{% else %}
|
||||
{% if b_height > thumbnail.get_height() %}
|
||||
{% set d_height = thumbnail.get_height() %}
|
||||
{% if b_height > thumbnail_height %}
|
||||
{% set d_height = thumbnail_height %}
|
||||
{% else %}
|
||||
{% set d_height = b_height %}
|
||||
{% endif %}
|
||||
{% set d_width = d_height * thumbnail.get_width() / thumbnail.get_height() %}
|
||||
{% set d_width = d_height * thumbnail_width / thumbnail_height %}
|
||||
{% set top = ((b_height - d_height) / 2) %}
|
||||
{% endif %}
|
||||
|
||||
@@ -37,8 +41,8 @@
|
||||
{% set random = thumbnail.get_random() %}
|
||||
<div class="record record_document imgTips" style="width:{{d_width|round}}px;height:{{d_height|round}}px;top:{{top|round}}px;">
|
||||
<div id="preview_{{thumbnail.get_base_id()}}_{{thumbnail.get_record_id()}}_{{random}}" class="PNB" style=""></div>
|
||||
<input type="hidden" name="width" value="{{thumbnail.get_width()}}"/>
|
||||
<input type="hidden" name="height" value="{{thumbnail.get_height()}}"/>
|
||||
<input type="hidden" name="width" value="{{thumbnail_width}}"/>
|
||||
<input type="hidden" name="height" value="{{thumbnail_height}}"/>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
swfobject.embedSWF("/include/FlexPaper_flash/FlexPaperViewer.swf",
|
||||
@@ -50,20 +54,20 @@
|
||||
{% set random = thumbnail.get_random() %}
|
||||
<div class="record record_audio audioTips" style="width:{{d_width|round}}px;height:{{d_height|round}}px;top:{{top|round}}px;">
|
||||
<div id="preview_{{thumbnail.get_base_id()}}_{{thumbnail.get_record_id()}}_{{random}}" class="PNB" style=""></div>
|
||||
<input type="hidden" name="width" value="{{thumbnail.get_width()}}"/>
|
||||
<input type="hidden" name="height" value="{{thumbnail.get_height()}}"/>
|
||||
<input type="hidden" name="width" value="{{thumbnail_width}}"/>
|
||||
<input type="hidden" name="height" value="{{thumbnail_height}}"/>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
swfobject.embedSWF("/include/jslibs/audio-player/player.swf",
|
||||
"preview_{{thumbnail.get_base_id()}}_{{thumbnail.get_record_id()}}_{{random}}",
|
||||
"{{thumbnail.get_width()}}", "{{thumbnail.get_height()}}", "9.0.0", false, false,
|
||||
"{{thumbnail_width}}", "{{thumbnail_height}}", "9.0.0", false, false,
|
||||
{menu: "false",flashvars: "playerID=2&autostart=yes&noinfo=yes&animation=no&remaining=yes&soundFile={{thumbnail.get_url()}}", movie: "/include/jslibs/audio-player/player.swf", allowFullScreen :"true",wmode: "transparent"}, false);</script>
|
||||
{% else %}
|
||||
<img class="record record_image imgTips zoomable thumb" oncontextMenu="return(false);"
|
||||
style="width:{{d_width|round}}px;height:{{d_height|round}}px;top:{{top|round}}px;"
|
||||
src="{{thumbnail.get_url()}}" ondragstart="return false;">
|
||||
<input type="hidden" name="width" value="{{thumbnail.get_width()}}"/>
|
||||
<input type="hidden" name="height" value="{{thumbnail.get_height()}}"/>
|
||||
<input type="hidden" name="width" value="{{thumbnail_width}}"/>
|
||||
<input type="hidden" name="height" value="{{thumbnail_height}}"/>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user