From bd96329e45a491ab8e521979dcc9d4b9cac11470 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 18 Nov 2010 19:30:15 -0800 Subject: [PATCH 1/3] New module that lets you force your thumbnails to be the aspect ratio of your choice. This effectively supercedes the square_thumb module since equivalent to specifying a 1:1 aspect ratio. --- .../helpers/rectangle_thumbs_graphics.php | 72 +++++++++++++++++++ .../helpers/rectangle_thumbs_installer.php | 29 ++++++++ 3.1/modules/rectangle_thumbs/module.info | 3 + 3 files changed, 104 insertions(+) create mode 100644 3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php create mode 100644 3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_installer.php create mode 100644 3.1/modules/rectangle_thumbs/module.info diff --git a/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php b/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php new file mode 100644 index 00000000..9334972c --- /dev/null +++ b/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php @@ -0,0 +1,72 @@ + $dims[0]) { + // Too wide, scale it down + list ($new_width, $new_height) = array($dims[0], $dims[0] / $desired_ratio); + } + + if ($new_height > $dims[1]) { + // Too tall, scale it down some more + $new_width = min($dims[0], $dims[1] * $desired_ratio); + $new_height = $new_width / $desired_ratio; + } + $new_width = round($new_width); + $new_height = round($new_height); + + Image::factory($input_file) + ->crop($new_width, $new_height) + ->quality(module::get_var("gallery", "image_quality")) + ->save($output_file); + } +} diff --git a/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_installer.php b/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_installer.php new file mode 100644 index 00000000..1fc6815c --- /dev/null +++ b/3.1/modules/rectangle_thumbs/helpers/rectangle_thumbs_installer.php @@ -0,0 +1,29 @@ + Date: Thu, 18 Nov 2010 19:31:22 -0800 Subject: [PATCH 2/3] Copied from 3.1/modules/rectangle_thumbs --- .../helpers/rectangle_thumbs_graphics.php | 72 +++++++++++++++++++ .../helpers/rectangle_thumbs_installer.php | 29 ++++++++ 3.0/modules/rectangle_thumbs/module.info | 3 + 3 files changed, 104 insertions(+) create mode 100644 3.0/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php create mode 100644 3.0/modules/rectangle_thumbs/helpers/rectangle_thumbs_installer.php create mode 100644 3.0/modules/rectangle_thumbs/module.info diff --git a/3.0/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php b/3.0/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php new file mode 100644 index 00000000..9334972c --- /dev/null +++ b/3.0/modules/rectangle_thumbs/helpers/rectangle_thumbs_graphics.php @@ -0,0 +1,72 @@ + $dims[0]) { + // Too wide, scale it down + list ($new_width, $new_height) = array($dims[0], $dims[0] / $desired_ratio); + } + + if ($new_height > $dims[1]) { + // Too tall, scale it down some more + $new_width = min($dims[0], $dims[1] * $desired_ratio); + $new_height = $new_width / $desired_ratio; + } + $new_width = round($new_width); + $new_height = round($new_height); + + Image::factory($input_file) + ->crop($new_width, $new_height) + ->quality(module::get_var("gallery", "image_quality")) + ->save($output_file); + } +} diff --git a/3.0/modules/rectangle_thumbs/helpers/rectangle_thumbs_installer.php b/3.0/modules/rectangle_thumbs/helpers/rectangle_thumbs_installer.php new file mode 100644 index 00000000..1fc6815c --- /dev/null +++ b/3.0/modules/rectangle_thumbs/helpers/rectangle_thumbs_installer.php @@ -0,0 +1,29 @@ + Date: Fri, 19 Nov 2010 11:57:20 -0800 Subject: [PATCH 3/3] New module that shows a tree of all albums in the sidebar. Selecting an album jumps to it. Probably very slow for large installs. --- .../albumtree/helpers/albumtree_block.php | 37 +++++++++++++++++++ 3.0/modules/albumtree/module.info | 3 ++ .../albumtree/views/albumtree_block.html.php | 24 ++++++++++++ .../albumtree/helpers/albumtree_block.php | 37 +++++++++++++++++++ 3.1/modules/albumtree/module.info | 3 ++ .../albumtree/views/albumtree_block.html.php | 24 ++++++++++++ 6 files changed, 128 insertions(+) create mode 100644 3.0/modules/albumtree/helpers/albumtree_block.php create mode 100644 3.0/modules/albumtree/module.info create mode 100644 3.0/modules/albumtree/views/albumtree_block.html.php create mode 100644 3.1/modules/albumtree/helpers/albumtree_block.php create mode 100644 3.1/modules/albumtree/module.info create mode 100644 3.1/modules/albumtree/views/albumtree_block.html.php diff --git a/3.0/modules/albumtree/helpers/albumtree_block.php b/3.0/modules/albumtree/helpers/albumtree_block.php new file mode 100644 index 00000000..8d184f51 --- /dev/null +++ b/3.0/modules/albumtree/helpers/albumtree_block.php @@ -0,0 +1,37 @@ + t("Album tree")); + } + + static function get($block_id) { + $block = new Block(); + switch ($block_id) { + case "albumtree": + $block->css_id = "g-albumtree"; + $block->title = t("Album Tree"); + $block->content = new View("albumtree_block.html"); + $block->content->root = item::root(); + break; + } + return $block; + } +} \ No newline at end of file diff --git a/3.0/modules/albumtree/module.info b/3.0/modules/albumtree/module.info new file mode 100644 index 00000000..d6c29a03 --- /dev/null +++ b/3.0/modules/albumtree/module.info @@ -0,0 +1,3 @@ +name = "Album Tree" +description = "Provides a block in the sidebar with quick links to all other albums." +version = 1 diff --git a/3.0/modules/albumtree/views/albumtree_block.html.php b/3.0/modules/albumtree/views/albumtree_block.html.php new file mode 100644 index 00000000..7cf66799 --- /dev/null +++ b/3.0/modules/albumtree/views/albumtree_block.html.php @@ -0,0 +1,24 @@ + + diff --git a/3.1/modules/albumtree/helpers/albumtree_block.php b/3.1/modules/albumtree/helpers/albumtree_block.php new file mode 100644 index 00000000..8d184f51 --- /dev/null +++ b/3.1/modules/albumtree/helpers/albumtree_block.php @@ -0,0 +1,37 @@ + t("Album tree")); + } + + static function get($block_id) { + $block = new Block(); + switch ($block_id) { + case "albumtree": + $block->css_id = "g-albumtree"; + $block->title = t("Album Tree"); + $block->content = new View("albumtree_block.html"); + $block->content->root = item::root(); + break; + } + return $block; + } +} \ No newline at end of file diff --git a/3.1/modules/albumtree/module.info b/3.1/modules/albumtree/module.info new file mode 100644 index 00000000..d6c29a03 --- /dev/null +++ b/3.1/modules/albumtree/module.info @@ -0,0 +1,3 @@ +name = "Album Tree" +description = "Provides a block in the sidebar with quick links to all other albums." +version = 1 diff --git a/3.1/modules/albumtree/views/albumtree_block.html.php b/3.1/modules/albumtree/views/albumtree_block.html.php new file mode 100644 index 00000000..7cf66799 --- /dev/null +++ b/3.1/modules/albumtree/views/albumtree_block.html.php @@ -0,0 +1,24 @@ + +