summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/gallery/libraries/Theme_View.php21
-rw-r--r--themes/wind/views/page.html.php2
2 files changed, 18 insertions, 5 deletions
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index 16c57794..da1e8ce8 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -58,17 +58,30 @@ class Theme_View_Core extends Gallery_View {
}
/**
- * Proportion of the current thumb_size's to default
+ * Proportion of the current thumb_size's to default.
+ *
+ * Themes can optionally use the $dimension parameter to choose which of the album's
+ * children will be used to determine the proportion. If set, the proportion will be
+ * calculated based on the child item with the largest width or height.
+ *
* @param object Item_Model (optional) check the proportions for this item
* @param int (optional) minimum thumbnail width
+ * @param string (optional) "width" or "height"
* @return int
*/
- public function thumb_proportion($item=null, $minimum_size=0) {
- // If the item is an album with children, grab the first item in that album instead. We're
+ public function thumb_proportion($item=null, $minimum_size=0, $dimension=null) {
+ if (!in_array($dimension, array("height", "width"))) {
+ $dimension = null;
+ }
+
+ // If the item is an album with children, grab an item from that album instead. We're
// interested in the size of the thumbnails in this album, not the thumbnail of the
// album itself.
if ($item && $item->is_album() && $item->children_count()) {
- $item = $item->children(1)->current();
+ $orderBy = (is_null($dimension)) ? array()
+ : array("thumb_".$dimension => "desc");
+
+ $item = $item->children(1, null, array(), $orderBy)->current();
}
// By default we have a globally fixed thumbnail size In core code, we just return a fixed
diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php
index 1dbb31c0..0ae41ea7 100644
--- a/themes/wind/views/page.html.php
+++ b/themes/wind/views/page.html.php
@@ -24,7 +24,7 @@
<link rel="apple-touch-icon-precomposed"
href="<?= url::file(module::get_var("gallery", "apple_touch_icon_url")) ?>" />
<? if ($theme->page_type == "collection"): ?>
- <? if (($thumb_proportion = $theme->thumb_proportion($theme->item(), 100)) != 1): ?>
+ <? if (($thumb_proportion = $theme->thumb_proportion($theme->item(), 100, "width")) != 1): ?>
<? $new_width = round($thumb_proportion * 213) ?>
<? $new_height = round($thumb_proportion * 240) ?>
<style type="text/css">