diff options
| author | colings <colings@example.com> | 2011-01-09 11:43:45 -0600 |
|---|---|---|
| committer | colings <colings@example.com> | 2011-01-09 11:43:45 -0600 |
| commit | 02a349f68ac480d5b1a630e14b4f2e3558328673 (patch) | |
| tree | 25bf25960b6811d8dbcbed6f6c9d63de7c03bd4e /modules/gallery/models | |
| parent | c2a1ea64eda2bf3e22ecaf4df4714c091bc5d7c4 (diff) | |
| parent | de5b06ae7442db2c7a8999c0c806997248ddb151 (diff) | |
Merge remote branch 'upstream/master'
Diffstat (limited to 'modules/gallery/models')
| -rw-r--r-- | modules/gallery/models/item.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index fc5c3ff9..88a444b4 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -653,7 +653,7 @@ class Item_Model_Core extends ORM_MPTT { /** * Calculate the largest width/height that fits inside the given maximum, while preserving the - * aspect ratio. + * aspect ratio. Don't upscale. * @param int $max Maximum size of the largest dimension * @return array */ @@ -661,6 +661,10 @@ class Item_Model_Core extends ORM_MPTT { $width = $this->thumb_width; $height = $this->thumb_height; + if ($width <= $max && $height <= $max) { + return array($height, $width); + } + if ($height) { if (isset($max)) { if ($width > $height) { @@ -1078,6 +1082,16 @@ class Item_Model_Core extends ORM_MPTT { return $data; } + /** + * Increments the view counter of this item + * We can't use math in ORM or the query builder, so do this by hand. It's important + * that we do this with math, otherwise concurrent accesses will damage accuracy. + */ + public function increment_view_count() { + db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $this->id") + ->execute(); + } + private function _cache_buster($path) { return "?m=" . (string)(file_exists($path) ? filemtime($path) : 0); } |
