diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-01-19 21:27:54 -0800 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-01-19 21:27:54 -0800 |
commit | 409c4dcc47c2da39cc8465b6975196cde07840fb (patch) | |
tree | d2bfa09d98afad25b5580ff67b5f4776d8f9a030 /modules/image_block | |
parent | e39c8df19fc0dadcfe65cb8a3ed6529648c6c9cf (diff) |
Do a better job of guarding against missing images.
Diffstat (limited to 'modules/image_block')
-rw-r--r-- | modules/image_block/helpers/image_block_block.php | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/modules/image_block/helpers/image_block_block.php b/modules/image_block/helpers/image_block_block.php index f28e775f..185df850 100644 --- a/modules/image_block/helpers/image_block_block.php +++ b/modules/image_block/helpers/image_block_block.php @@ -26,14 +26,13 @@ class image_block_block_Core { $block = ""; switch ($block_id) { case "random_image": - $block = new Block(); - $block->css_id = "g-image-block"; - $block->title = t("Random image"); - $block->content = new View("image_block_block.html"); - $block->content->items = item::random_query(array(array("type", "!=", "album")))->find_all(1); - - if ($block->content->items->count() == 0) { - $block = ""; + $item = item::random_query(array(array("type", "!=", "album")))->find_all(1)->current(); + if ($item && $item->loaded()) { + $block = new Block(); + $block->css_id = "g-image-block"; + $block->title = t("Random image"); + $block->content = new View("image_block_block.html"); + $block->content->item = $item; } break; } |