Ansel_Gallery::removeImage PHP Method

removeImage() public method

Remove the given image from this gallery.
public removeImage ( mixed $image, boolean $isStack = false )
$image mixed Image to delete. Can be an Ansel_Image or an image ID.
$isStack boolean Indicates if this image represents a stack image.
    public function removeImage($image, $isStack = false)
    {
        $this->_modeHelper->removeImage($image, $isStack);
    }

Usage Example

示例#1
0
 /**
  * Empties a gallery of all images.
  *
  * @param Ansel_Gallery $gallery  The ansel gallery to empty.
  *
  * @throws Ansel_Exception
  */
 public function emptyGallery(Ansel_Gallery $gallery)
 {
     $gallery->clearStacks();
     $images = $gallery->listImages();
     foreach ($images as $image) {
         // Pretend we are a stack so we don't update the images count
         // for every image deletion, since we know the end result will
         // be zero.
         try {
             $gallery->removeImage($image, true);
         } catch (Horde_Exception_NotFound $e) {
             // Don't worry about missing images since we are deleting them
             // anyway.
             Horde::log($e->getMessage(), 'ERR');
         }
     }
     $gallery->set('images', 0, true);
     // Clear the OtherGalleries widget cache
     if ($GLOBALS['conf']['ansel_cache']['usecache']) {
         $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_OtherGalleries' . $gallery->get('owner'));
         $GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_Gallery' . $gallery->id);
     }
 }