summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-03-20 20:33:20 +0000
committerBharat Mediratta <bharat@menalto.com>2009-03-20 20:33:20 +0000
commite1c53921d3ac4574486b420d6da9c2843f144d76 (patch)
tree7b0614b0390e23ae4ab7d8b9c38036480cbc2b68
parentb942930c70a077279815b5ab7e59c98e82209fb5 (diff)
Don't divide by zero in thumb_tag if there's no thumbnail
-rw-r--r--core/models/item.php22
1 files changed, 15 insertions, 7 deletions
diff --git a/core/models/item.php b/core/models/item.php
index 2bfecc76..4790e31a 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -328,14 +328,22 @@ class Item_Model extends ORM_MPTT {
public function thumb_tag($extra_attrs, $max=null) {
$width = $this->thumb_width;
$height = $this->thumb_height;
- if (isset($max)) {
- if ($width > $height) {
- $height = (int)($max * ($height / $width));
- $width = $max;
- } else {
- $width = (int)($max * ($width / $height));
- $height = $max;
+
+ if ($height) {
+ if (isset($max)) {
+ if ($width > $height) {
+ $height = (int)($max * ($height / $width));
+ $width = $max;
+ } else {
+ $width = (int)($max * ($width / $height));
+ $height = $max;
+ }
}
+ } else {
+ // Missing thumbnail, can happen on albums with no photos yet.
+ // @todo we should enforce a placeholder for those albums.
+ $width = 0;
+ $height = 0;
}
$attrs = array_merge($extra_attrs,
array(