To allow for easier theming, ImageGenerator classes for thumbnails are now named as:
Ansel_ImageGenerator_{type}Thumb
and if there is a matching stack generator, it should be named as:
Ansel_ImageGenerator_{type}ThumbStack
other types of generators, such as the screen, and mini generators, are named as before:
Ansel_ImageGenerator_Screen, Ansel_ImageGenerator_Mini etc...
header('X-Sendfile: ' . $filename);
exit;
}
-$image->display('mini');
+$image->display('mini', Ansel::getStyleDefinition('ansel_default'));
}
}
+ public function get($property)
+ {
+ $value = parent::get($property);
+ if ($property == 'style') {
+ $value = unserialize($value);
+ }
+
+ return $value;
+ }
+
/**
* Check for special capabilities of this gallery.
*
$style = $this->getStyle();
}
- if ($style->default_galleryimage_type != 'plain') {
- $thumbstyle = $style->default_galleryimage_type;
+ if ($style->keyimage_type != 'Thumb') {
+ $thumbstyle = $style->keyimage_type;
$styleHash = $style->getHash($thumbstyle);
/* First check for the existence of a key image in the specified style */
//@TODO: Look at passing style both in params and the property...
$params = array('gallery' => $this, 'style' => $style);
try {
- $iview = Ansel_ImageGenerator::factory($style->default_galleryimage_type, $params);
+ $iview = Ansel_ImageGenerator::factory($style->keyimage_type, $params);
$img = $iview->create();
// Note the gallery_id is negative for generated stacks
// Might not support the requested style...try ansel_default
// but protect against infinite recursion.
Horde::logMessage($e->getMessage(), 'DEBUG');
- if ($style->default_galleryimage_type != 'plain') {
+ if ($style->keyimage_type != 'plain') {
return $this->getKeyImage(Ansel::getStyleDefinition('ansel_default'));
}
}
$this->_setModeHelper($mode);
}
+ /* Need to serialize the style object */
+ if ($driver_key == 'attribute_style') {
+ $value = serialize($value);
+ }
+
$this->data[$driver_key] = $value;
/* Update the backend, but only this current change */
+++ /dev/null
-<?php
-/**
- * ImageGenerator to create the gallery image stacks.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Ansel
- */
-class Ansel_ImageGenerator_PlainStack extends Ansel_ImageGenerator
-{
- public $need = array('PhotoStack');
-
- /**
- *
- * @return Horde_Image
- */
- protected function _create()
- {
- $imgobjs = $this->_getStackImages();
- $style = $this->_params['style'];
- $params = array('width' => 100,
- 'height' => 100,
- 'background' => $style->background);
-
- $baseImg = Ansel::getImageObject($params);
- try {
- $baseImg->addEffect(
- 'PhotoStack',
- array('images' => $imgobjs,
- 'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
- 'padding' => 0,
- 'background' => $style->background,
- 'type' => 'plain'));
-
- $baseImg->applyEffects();
- $baseImg->resize($GLOBALS['conf']['thumbnail']['width'],
- $GLOBALS['conf']['thumbnail']['height']);
- } catch (Horde_Image_Exception $e) {
- throw new Ansel_Exception($e);
- }
-
- return $baseImg;
- }
-
-}
+++ /dev/null
-<?php
-/**
- * ImageGenerator to create the gallery polaroid stacks.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Ansel
- */
-class Ansel_ImageGenerator_PolaroidStack extends Ansel_ImageGenerator
-{
- public $need = array('PhotoStack');
-
- /**
- *
- * @return Horde_Image
- */
- protected function _create()
- {
- $imgobjs = $this->_getStackImages();
- $style = $this->_params['style'];
- $params = array('width' => 100,
- 'height' => 100,
- 'background' => $style->background);
-
- $baseImg = Ansel::getImageObject($params);
- try {
- $baseImg->addEffect(
- 'PhotoStack',
- array('images' => $imgobjs,
- 'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
- 'padding' => 10,
- 'background' => $style->background,
- 'type' => 'polaroid'));
- $baseImg->applyEffects();
- $baseImg->resize($GLOBALS['conf']['thumbnail']['width'],
- $GLOBALS['conf']['thumbnail']['height']);
-
- } catch (Horde_Image_Exception $e) {
- throw new Ansel_Exception($e);
- }
-
- return $baseImg;
- }
-
-}
--- /dev/null
+<?php
+/**
+ * ImageGenerator to create the gallery polaroid stacks.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ */
+class Ansel_ImageGenerator_PolaroidThumbStack extends Ansel_ImageGenerator
+{
+ public $need = array('PhotoStack');
+
+ /**
+ *
+ * @return Horde_Image
+ */
+ protected function _create()
+ {
+ $imgobjs = $this->_getStackImages();
+ $style = $this->_params['style'];
+ $params = array('width' => 100,
+ 'height' => 100,
+ 'background' => $style->background);
+
+ $baseImg = Ansel::getImageObject($params);
+ try {
+ $baseImg->addEffect(
+ 'PhotoStack',
+ array('images' => $imgobjs,
+ 'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
+ 'padding' => 10,
+ 'background' => $style->background,
+ 'type' => 'polaroid'));
+ $baseImg->applyEffects();
+ $baseImg->resize($GLOBALS['conf']['thumbnail']['width'],
+ $GLOBALS['conf']['thumbnail']['height']);
+
+ } catch (Horde_Image_Exception $e) {
+ throw new Ansel_Exception($e);
+ }
+
+ return $baseImg;
+ }
+
+}
+++ /dev/null
-<?php
-/**
- * ImageGenerator to create the prettythumb view (rounded, shadowed thumbnails).
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Ansel
- */
-class Ansel_ImageGenerator_PrettyThumb extends Ansel_ImageGenerator
-{
- public $need = array('RoundCorners', 'DropShadow');
-
- /**
- *
- * @return Horde_Image
- */
- protected function _create()
- {
- $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
- min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
- true);
-
- /* Don't bother with these effects for a stack image
- * (which will have a negative gallery_id). */
- if ($this->_image->gallery > 0) {
- if (is_null($this->_style)) {
- $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
- $styleDef = $gal->getStyle();
- } else {
- $styleDef = $this->_style;
- }
-
- try {
- /* Apply the effects - continue on error, but be sure to log */
- $this->_image->addEffect('RoundCorners', array('border' => 2,
- 'bordercolor' => '#333'));
-
- $this->_image->addEffect('DropShadow', array('background' => $styleDef->background,
- 'padding' => 5,
- 'distance' => 5,
- 'fade' => 3));
- if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
- $this->_image->addEffect('Unsharpmask',
- array('radius' => $GLOBALS['conf']['thumbnail']['radius'],
- 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'],
- 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
- }
-
- $this->_image->applyEffects();
- } catch (Horde_Image_Exception $e) {
- throw new Ansel_Exception($e);
- }
-
- return $this->_image->getHordeImage();
- }
- }
-
-}
+++ /dev/null
- <?php
-/**
- * ImageGenerator to create the gallery image stacks.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Ansel
- *
- */
-class Ansel_ImageGenerator_RoundedStack extends Ansel_ImageGenerator
- {
- public $need = array('PhotoStack');
-
- /**
- *
- * @return Horde_Image
- */
- protected function _create()
- {
- $imgobjs = $this->_getStackImages();
- $style = $this->_params['style'];
- $params = array('width' => 100,
- 'height' => 100,
- 'background' => $style->background);
-
- $baseImg = Ansel::getImageObject($params);
-
- try {
- $baseImg->addEffect(
- 'PhotoStack',
- array('images' => $imgobjs,
- 'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
- 'padding' => 0,
- 'background' => $style->background,
- 'type' => 'rounded'));
-
- $baseImg->applyEffects();
- $baseImg->resize($GLOBALS['conf']['thumbnail']['width'],
- $GLOBALS['conf']['thumbnail']['height']);
- } catch (Horde_Image_Exception $e) {
- throw new Ansel_Exception($e);
- }
-
- return $baseImg;
- }
-
-}
--- /dev/null
+<?php
+/**
+ * ImageGenerator to create the prettythumb view (rounded, shadowed thumbnails).
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ */
+class Ansel_ImageGenerator_RoundedThumb extends Ansel_ImageGenerator
+{
+ public $need = array('RoundCorners', 'DropShadow');
+
+ /**
+ *
+ * @return Horde_Image
+ */
+ protected function _create()
+ {
+ $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
+ min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
+ true);
+
+ /* Don't bother with these effects for a stack image
+ * (which will have a negative gallery_id). */
+ if ($this->_image->gallery > 0) {
+ if (is_null($this->_style)) {
+ $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
+ $styleDef = $gal->getStyle();
+ } else {
+ $styleDef = $this->_style;
+ }
+
+ try {
+ /* Apply the effects - continue on error, but be sure to log */
+ $this->_image->addEffect('RoundCorners', array('border' => 2,
+ 'bordercolor' => '#333'));
+
+ $this->_image->addEffect('DropShadow', array('background' => $styleDef->background,
+ 'padding' => 5,
+ 'distance' => 5,
+ 'fade' => 3));
+ if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
+ $this->_image->addEffect('Unsharpmask',
+ array('radius' => $GLOBALS['conf']['thumbnail']['radius'],
+ 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'],
+ 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
+ }
+
+ $this->_image->applyEffects();
+ } catch (Horde_Image_Exception $e) {
+ throw new Ansel_Exception($e);
+ }
+
+ return $this->_image->getHordeImage();
+ }
+ }
+
+}
--- /dev/null
+ <?php
+/**
+ * ImageGenerator to create the gallery image stacks.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ *
+ */
+class Ansel_ImageGenerator_RoundedThumbStack extends Ansel_ImageGenerator
+ {
+ public $need = array('PhotoStack');
+
+ /**
+ *
+ * @return Horde_Image
+ */
+ protected function _create()
+ {
+ $imgobjs = $this->_getStackImages();
+ $style = $this->_params['style'];
+ $params = array('width' => 100,
+ 'height' => 100,
+ 'background' => $style->background);
+
+ $baseImg = Ansel::getImageObject($params);
+
+ try {
+ $baseImg->addEffect(
+ 'PhotoStack',
+ array('images' => $imgobjs,
+ 'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
+ 'padding' => 0,
+ 'background' => $style->background,
+ 'type' => 'rounded'));
+
+ $baseImg->applyEffects();
+ $baseImg->resize($GLOBALS['conf']['thumbnail']['width'],
+ $GLOBALS['conf']['thumbnail']['height']);
+ } catch (Horde_Image_Exception $e) {
+ throw new Ansel_Exception($e);
+ }
+
+ return $baseImg;
+ }
+
+}
+++ /dev/null
-<?php
-/**
- * ImageGenerator to create the shadowsharpthumb view (sharp corners, shadowed)
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Ansel
- */
-class Ansel_ImageGenerator_ShadowSharpThumb extends Ansel_ImageGenerator
-{
- public $need = array('DropShadow');
-
- /**
- *
- * @return boolean
- */
- protected function _create()
- {
- $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
- min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
- true);
-
- /* Don't bother with these effects for a stack image
- * (which will have a negative gallery_id). */
- if ($this->_image->gallery > 0) {
- if (is_null($this->_style)) {
- $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
- $styleDef = $gal->getStyle();
- } else {
- $styleDef = $this->_style;
- }
-
- try {
- $this->_image->addEffect('Border', array('bordercolor' => '#333', 'borderwidth' => 1));
- $this->_image->addEffect('DropShadow',
- array('background' => $styleDef->background,
- 'padding' => 5,
- 'distance' => 8,
- 'fade' => 2));
-
- if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
- $this->_image->addEffect('Unsharpmask',
- array('radius' => $GLOBALS['conf']['thumbnail']['radius'],
- 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'],
- 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
- $this->_image->applyEffects();
- }
-
- $this->_image->applyEffects();
- } catch (Horde_Image_Exception $e) {
- throw new Ansel_Exception($e);
- }
-
- return $this->_image->getHordeImage();
- }
- }
-
-}
--- /dev/null
+<?php
+/**
+ * ImageGenerator to create the shadowsharpthumb view (sharp corners, shadowed)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ */
+class Ansel_ImageGenerator_ShadowThumb extends Ansel_ImageGenerator
+{
+ public $need = array('DropShadow');
+
+ /**
+ *
+ * @return boolean
+ */
+ protected function _create()
+ {
+ $this->_image->resize(min($GLOBALS['conf']['thumbnail']['width'], $this->_dimensions['width']),
+ min($GLOBALS['conf']['thumbnail']['height'], $this->_dimensions['height']),
+ true);
+
+ /* Don't bother with these effects for a stack image
+ * (which will have a negative gallery_id). */
+ if ($this->_image->gallery > 0) {
+ if (is_null($this->_style)) {
+ $gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($this->_image->gallery);
+ $styleDef = $gal->getStyle();
+ } else {
+ $styleDef = $this->_style;
+ }
+
+ try {
+ $this->_image->addEffect('Border', array('bordercolor' => '#333', 'borderwidth' => 1));
+ $this->_image->addEffect('DropShadow',
+ array('background' => $styleDef->background,
+ 'padding' => 5,
+ 'distance' => 8,
+ 'fade' => 2));
+
+ if ($GLOBALS['conf']['thumbnail']['unsharp'] && Ansel::isAvailable('Unsharpmask')) {
+ $this->_image->addEffect('Unsharpmask',
+ array('radius' => $GLOBALS['conf']['thumbnail']['radius'],
+ 'threshold' => $GLOBALS['conf']['thumbnail']['threshold'],
+ 'amount' => $GLOBALS['conf']['thumbnail']['amount']));
+ $this->_image->applyEffects();
+ }
+
+ $this->_image->applyEffects();
+ } catch (Horde_Image_Exception $e) {
+ throw new Ansel_Exception($e);
+ }
+
+ return $this->_image->getHordeImage();
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * ImageGenerator to create the gallery image stacks.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Ansel
+ */
+class Ansel_ImageGenerator_ShadowThumbStack extends Ansel_ImageGenerator
+{
+ public $need = array('PhotoStack');
+
+ /**
+ *
+ * @return Horde_Image
+ */
+ protected function _create()
+ {
+ $imgobjs = $this->_getStackImages();
+ $style = $this->_params['style'];
+ $params = array('width' => 100,
+ 'height' => 100,
+ 'background' => $style->background);
+
+ $baseImg = Ansel::getImageObject($params);
+ try {
+ $baseImg->addEffect(
+ 'PhotoStack',
+ array('images' => $imgobjs,
+ 'resize_height' => $GLOBALS['conf']['thumbnail']['height'],
+ 'padding' => 0,
+ 'background' => $style->background,
+ 'type' => 'plain'));
+
+ $baseImg->applyEffects();
+ $baseImg->resize($GLOBALS['conf']['thumbnail']['width'],
+ $GLOBALS['conf']['thumbnail']['height']);
+ } catch (Horde_Image_Exception $e) {
+ throw new Ansel_Exception($e);
+ }
+
+ return $baseImg;
+ }
+
+}
public function __construct($properties)
{
$this->_properties = array_merge(array('gallery_view' => 'Gallery',
- 'default_galleryimage_type' => 'plain',
'background' => 'none'),
$properties);
}
public function &__get($property)
{
+ if ($property == 'keyimage_type') {
+ // Force the same type of effect for key image/stacks if available
+ $class = $this->_properties['thumbstyle'] . 'Stack';
+ if (!class_exists('Ansel_ImageGenerator_' . $class)) {
+ $class = 'Thumb';
+ }
+
+ return $class;
+ }
+
return $this->_properties[$property];
}
// Style
$style = new Ansel_Style(array(
'thumbstyle' => Horde_Util::getFormData('thumbnail_style'),
- 'default_galleryimage_type' => 'PlainStack',//Horde_Util::getFormData('keyimage_type'),
'background' => Horde_Util::getFormData('background_color'),
// temporary hack
'widgets' => array('Actions' => array(),
<td>
<select name="thumbnail_style">
<option value="Thumb" selected="selected">Basic Thumbnails</option>
- <option value="ShadowSharpThumb">Drop Shadows</option>
- <option value="PrettyThumb">Rounded Corners</option>
+ <option value="ShadowThumb">Drop Shadows</option>
+ <option value="RoundedThumb">Rounded Corners</option>
<option value="PolaroidThumb">Polaroids</option>
</select>
</td>
</tr>
+<!-- <tr>
+ <td align="right" valign="top"><strong><?php echo _("Key Image Style"); ?></string></td>
+ <td>
+ <select name="keyimage_type">
+ <option value="Thumb">Basic Thumbnail</option>
+ <option value="PlainStack">Photo Stack</option>
+ <option value-="RoundedStack">Rounded Stack</option>
+ <option value="PolaroidStack">Polaroid Stack</option>
+ </select>
+ </td>
+ </tr>-->
<tr>
<td align="right" valign="top"><strong><?php echo _("Backgrond Color"); ?></string></td>
<td>
<?php for ($i = 0; $i < count($mini_galleries); ++$i): ?>
<td align="center">
<?php if ($mini_galleries[$i]->isOldEnough() && !$mini_galleries[$i]->hasPasswd()): ?>
- <?php echo $link ?><img src="<?php echo Ansel::getImageUrl($mini_galleries[$i]->getKeyImage(), 'mini', false) ?>" alt="<?php echo $owner_title?>" /></a>
+ <?php echo $link ?><img src="<?php echo Ansel::getImageUrl($mini_galleries[$i]->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'mini', false) ?>" alt="<?php echo $owner_title?>" /></a>
<?php else: ?>
<?php echo $link . Horde::img('gallery-locked-mini.png') ?></a>
<?php endif; ?>