Add Derivative to GalleryItem

mecs

Joined: 2008-08-28
Posts: 2
Posted: Thu, 2008-08-28 10:34

Hi,

I'm trying to add Derivatives to existing GalleryItems.

I hoped to find a function like: addDerivativeToItem($parentItem, $derivativeFilename);
Since I couldn't find something like that I thought about creating a GalleryDerivative-Object and assign the file to it. But GalleryDerivative doesn't seem to represent a file...

Does anyone have an advice how to add a custom Derivative to an existing GalleryItem?

Greetings from Germany
mecs

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2008-08-28 10:50

GalleryDerivative is not a subclass of GalleryFileSystemEntity and can't own a file. GalleryDerivatives must be derived (hence the name) from a GalleryItem with a sequence of 'operations' like resize, rotate, add watermark etc.

If an item has its own file it should be a subclass of GalleryFileSystemEntity, such as a GalleryItem.

 
mecs

Joined: 2008-08-28
Posts: 2
Posted: Fri, 2008-09-05 11:42

Thanks, that (and a look at the thumbnail-module) really helped me.
Now I'm able to add Items to the Gallery. My new problem is that my created Items are not included in $theme.imageViews, although I set the parent-field.
How is the data for $theme.imageViews collected and what do I have to do to have my item included?

Thanks in advance
mecs

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Fri, 2008-09-05 11:59
Quote:
How is the data for $theme.imageViews collected

in GalleryTheme::loadCommonTemplateData(...)

You're trying to add a custom derivative that is actually a different file, right? Then, yes, the thumbnail-module method is the way to go. But I don't think that the gallery structure is flexible enough to do what you want, since the thumbnail concept is built-in, whereas your own 'underived-derivative' isn't.

the $theme.imageViews is hard-coded to be built from some selection of the original item, the resizes and the thumbnail - I don't see a hook where you can slot in something else.