diff options
author | Bharat Mediratta <bharat@menalto.com> | 2011-03-20 10:25:59 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2011-03-20 10:25:59 -0700 |
commit | dc21cf36b606048dc24532407d39bc8f5b4211fa (patch) | |
tree | 1a9cd75bff7342f216484882fa3564184a478368 /modules/gallery/libraries/Theme_View.php | |
parent | e4d4a89a1bd54164fb62d95ac62a44957d124e68 (diff) |
Change the $thumb_proportions variable to be a theme callback which
takes an item as an argument. This will let us figure out proportions
in the case where a module has defined custom thumbnail sizes.
Diffstat (limited to 'modules/gallery/libraries/Theme_View.php')
-rw-r--r-- | modules/gallery/libraries/Theme_View.php | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index a507e9c8..d0b35d3e 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -42,9 +42,6 @@ class Theme_View_Core extends Gallery_View { "page_type" => $page_type, "page_subtype" => $page_subtype, "page_title" => null)); - if ($page_type == "collection") { - $this->set_global("thumb_proportion", $this->thumb_proportion()); - } if (module::get_var("gallery", "maintenance_mode", 0)) { if (identity::active_user()->admin) { @@ -58,10 +55,17 @@ class Theme_View_Core extends Gallery_View { * Proportion of the current thumb_size's to default * @return int */ - public function thumb_proportion() { - // @TODO change the 200 to a theme supplied value when and if we come up with an - // API to allow the theme to set defaults. - return module::get_var("gallery", "thumb_size", 200) / 200; + public function thumb_proportion($item) { + // By default we have a globally fixed thumbnail size In core code, we just return a fixed + // proportion based on the global thumbnail size, but since modules can override that, we + // return the actual proportions when we have them. + if ($item->has_thumb()) { + return max($item->thumb_width, $item->thumb_height) / 200; + } else { + // @TODO change the 200 to a theme supplied value when and if we come up with an + // API to allow the theme to set defaults. + return module::get_var("gallery", "thumb_size", 200) / 200; + } } public function item() { |