Create Resizes Only If Needed

alexisb
alexisb's picture

Joined: 2005-11-24
Posts: 56
Posted: Mon, 2006-05-08 19:00

Hi, I need to create derivatives of a certain size from my own module code and wanted to know how to avoid creating "repeated" derivatives.

I've been following Valiant's suggestions for creating a derivative image using the code from ItemEditPhoto.inc using ideas from this thread.

But I'm not too sure about this:

Quote:
as i explained before, you'll have to copy code from modules/core/ItemEditPhoto.inc function handleRequest.

then you can run

list ($ret, $derivative, $wasBuilt) =
GalleryCoreApi::rebuildDerivativeCacheIfNotCurrent($resize->getId(), true);
if ($ret) {
return array($ret->wrap(__FILE__, __LINE__), null, null);
}

to generate the binary image file.

Is GalleryCoreApi::rebuildDerivativeCacheIfNotCurrent the correct method for avoiding creating a new derivative for the same size?

If I create a 500px width derivate of a certain itemId how can I make sure not to create another 500px width for the same itemId?

Thanks for your help!

Alexis Bellido - Ventanazul web solutions