[dev] Ansel storeImage, numImages, getImageUrl,
getDefaultImage API calls
Duck
duck at obala.net
Sun Oct 10 04:18:45 PDT 2004
On Sunday 10 of October 2004 05:02, Chuck Hagenbuch wrote:
> Quoting Duck <duck at obala.net>:
> > I resubmit the patch of storeImage Ansel API call. This one returns
> > PEAR:Errors on error and the "permission" parameter for gallery creation.
> > I also added numImages, getImageUrl and getDefaultImage functions
>
> This looks interesting (I have it applied and cleaned up locally - btw,
> please take a read through horde/docs/CODING_STANDARDS for spacing
> stuff...), but it also seems like a fairly awkward API. Are you using this
> anywhere? How would you envision it being used? Etc...
>
> -chuck
yes. I'm using it in an article management and user profiles module, where I
sore article image in Ansel and user image.
An basic example how I use it in the article manager. (Using VFS direct).
In a Horde_Form I have an image variable called "picture". When the form is
submitted I store the image id like this.
if ( getimagesize(@$info['picture']['file']) !== FALSE ) {
$image = $registry->call('photos/saveImage', array('news',
$id,
$info['picture'],
true,
$conf['images'],
null) );
if (!is_a($image, 'PEAR_error')) {
$sth = $news->db->prepare("UPDATE news SET picture=? WHERE id=?");
$news->db->execute($sth, array($image['image-id'], $id));
}
}
Then, in the article browsing, I output the image like this:
$image_data = array("news", $row["picture"], "thumb", false);
$img = $registry->call("photos/getImageUrl", $image_data);
echo Horde::img($img, stripslashes($row["title"]), '', '') ;
The $conf['images'] consist of an configuration array of the thumbnail and
image dimensions. I attached the conf.xml part I add to the modules where I
use this calls.
Duck
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dimension.xml
Type: text/xml
Size: 402 bytes
Desc: not available
Url : http://lists.horde.org/archives/dev/attachments/20041010/dc0e3272/dimension.xml
More information about the dev
mailing list