diff options
-rw-r--r-- | core/helpers/core_block.php | 2 | ||||
-rw-r--r-- | core/helpers/photo.php | 17 | ||||
-rw-r--r-- | core/views/admin_block_photo_stream.html.php | 9 |
3 files changed, 24 insertions, 4 deletions
diff --git a/core/helpers/core_block.php b/core/helpers/core_block.php index 0e9ee27b..79fc0bf4 100644 --- a/core/helpers/core_block.php +++ b/core/helpers/core_block.php @@ -47,6 +47,8 @@ class core_block_Core { $block->id = "gPhotoStream"; $block->title = _("Photo Stream"); $block->content = new View("admin_block_photo_stream.html"); + $block->content->photos = + ORM::factory("item")->where("type", "photo")->orderby("created", "desc")->find_all(10); $blocks[] = $block; $block = new Block(); diff --git a/core/helpers/photo.php b/core/helpers/photo.php index 00aff447..bb470e58 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -104,4 +104,21 @@ class photo_Core { return $form; } + /** + * Return scaled width and height. + * + * @param Item_Model the photo + * @param integer the scaling factor + * @param string the output format using %d placeholders for width and height + */ + static function img_dimensions($photo, $max, $format="width=\"%d\" height=\"%d\"") { + if ($photo->width > $photo->height) { + $width = $max; + $height = (int)$max * ($photo->height / $photo->width); + } else { + $height = $max; + $width = (int)$max * ($photo->width / $photo->height); + } + return sprintf($format, $width, $height); + } } diff --git a/core/views/admin_block_photo_stream.html.php b/core/views/admin_block_photo_stream.html.php index 3255fb04..af8d8545 100644 --- a/core/views/admin_block_photo_stream.html.php +++ b/core/views/admin_block_photo_stream.html.php @@ -2,7 +2,8 @@ <p> Recent photos added to your Gallery </p> -<img src="<?= $theme->url("images/photostream.png") ?>" alt="" /> -<p class="gWarning"> - Slider type of display. Show titles underneath or on hover. Draw a keyline around albums, or differentiate some how. Each will be linked to item view -</p> +<? foreach ($photos as $photo): ?> +<a href="<?= url::site("photos/$photo->id") ?>"> + <img <?= photo::img_dimensions($photo, 72) ?> src="<?= $photo->thumb_url() ?>" alt="" /> +</a> +<? endforeach ?> |