Hi all!
I'm trying to create a little plugin for the french CMS SPIP.
I'm not using the integration API provided by Gallery2, because I only need to retrieve images from the albums, and I don't need to integrate the others Gallery's functions.
Could someone suggest me the correct syntax of a SQL query than can select all the images belonging to a given album?
Thanks a lot.
Bye
Posts: 4342
SELECT [GalleryPhotoItem::id] FROM [GalleryPhotoItem] INNER JOIN [GalleryChildEntity]
WHERE [GalleryPhotoItem::id] = [GalleryChildEntity::id]
AND [GalleryChildEntity::parentId] = <put the album id here>
You'll need to convert Gallery's internal SQL-like code to the syntax of whichever database your gallery is using, including changing the Table prefixes from Gallery... to (by default) g2_... and add g_... as the default column prefix as well.
Posts: 32509
but the API makes things a lot easier...
see: docs -> maintenance -> how to write scripts.
- init G2 by including embed.php and calling GalleryEmbed::init().
- load the album: list ($ret, $albumItem) = GalleryCoreApi::loadEntitiesById($id=7); // param is the integer id of some album item
- get the ids of the children: list ($ret, $childIds) = GalleryCoreApi::fetchChildItemIds($albumItem);
- now you can load thumbnails, resizes or the original size images: ...
- to get the titles, descriptions of the images, load their objects: list ($ret, $children) = GalleryCoreApi::loadEntitiesById($childIds);
foreach ($children as $child) { print $child->getTitle(); } // etc.
- to get a URL to an image file (thumb, resize or original size):
$urlGenerator =& $gallery->getUrlGenerator();
$url = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $thumbnail->getId(), 'serialNumber' => $thumbnail->getSerialNumber())); // image URL
$url = $urlGenerator->generateUrl(array('view' => 'core.ShowItem', 'itemId' => $child->getId())); // HTML page URL
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Thanks a lot.
I'll try the API.
I need help in using the API...
Where should I find an easy tutorial about API use?
Posts: 32509
- see: docs -> maintenance -> how to write scripts.
- development (link in the top right)
- existing code. take a look at modules/core/*.inc, modules/core/*/helpers/*
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Thanks valiant.
I'm in a hurry with this plugin, so Your help is very appreciated.
I've managed to use the API, but I still have problems in getting an image thumbnail.
I'm a little confused about the three Thumbnail classes (Helper, Toolkit and Image).
Well, what should I do to get a thumbnail from a GalleryEntity object?
Thanks.
Posts: 1378
ubik15,
Grab a copy of one of the embedded applications, ie WPG2 and have a look at how we have done it.. If you are looking at say the WPG2 / G2image then you can see how the code works by looking into the g2image.php - function g2ic_get_item_info($item_id) but as a hint list($error, $thumbnails) = GalleryCoreApi::fetchThumbnailsByItemIds(array($item->getid())); will help ;)
____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo
Posts: 25
YOU MADE MY DAY, THANK YOU SO MUCH!