mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-08-22 23:05:18 -04:00
Do a better job of guarding against missing images.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user