Skip to content

Commit

Permalink
Protect against errors getting keyImage when gallery has no images.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Jan 19, 2017
1 parent bc3a1bd commit 273d936
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ansel/lib/Gallery.php
Expand Up @@ -772,10 +772,13 @@ public function getKeyImage(Ansel_Style $style = null)
}

// Don't already have one, must generate it.
$default = $this->getKeyImage(Ansel::getStyleDefinition('ansel_default'));
if (!($default = $this->getKeyImage(Ansel::getStyleDefinition('ansel_default')))) {
// No images in gallery yet.
return false;
}
$params = array('gallery' => $this, 'style' => $style, 'image' => $storage->getImage($default));
try {
if (!$params['image'] = $this->getImage($this->_getDefaultImageId())) {
if (!($params['image'] = $this->getImage($this->_getDefaultImageId()))) {
return false;
}
$iview = Ansel_ImageGenerator::factory($style->keyimage_type, $params);
Expand Down

0 comments on commit 273d936

Please sign in to comment.