<?
$pics = get_gallery_images('69');
echo '<pre>';
print_r($pics);
echo '</pre>';
function get_gallery_images($gallery_id){
$pictures = array();
$count = 0;
require_once('/home/www/mikerochford.com/htdocs/p/embed.php');
$ret = GalleryEmbed::init(array('embedUri' => '/p/index.php','embedPath' => '/p','relativeG2Path' => '','fullInit' => true));
list ($ret, $albumItem) = GalleryCoreApi::loadEntitiesById($id=$gallery_id); // param is the integer id of some album item
list ($ret, $childIds) = GalleryCoreApi::fetchChildItemIds($albumItem);
list ($ret, $children) = GalleryCoreApi::loadEntitiesById($childIds);
$urlGenerator =& $gallery->getUrlGenerator();
foreach ($children as $child) {
$pictures[$count]['title'] = $child->title;
$pictures[$count]['width'] = $child->width;
$pictures[$count]['height'] = $child->height;
$big_pic = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $child->getId(), 'serialNumber' => $child->getSerialNumber())); // image URL
preg_match('/(.+)\?/',$big_pic,$matches);
$pictures[$count]['large_picture'] = $matches[1];
list($ret, $thumbnails) = GalleryCoreApi::fetchThumbnailsByItemIds(array($child->getid()));
foreach($thumbnails as $thumbnail) {
$thumb_pic = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $thumbnail->getId(), 'serialNumber' => $thumbnail->getSerialNumber())); // image URL
preg_match('/(.+)\?/',$thumb_pic,$matches);
$pictures[$count]['thumb_picture'] = $matches[1];
}
list($ret, $resized) = GalleryCoreApi::fetchResizesByItemIds(array($child->getid()));
foreach($resized as $resize){
foreach($resize as $res){
$resize_pic = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $res->getId(), 'serialNumber' => $res->getSerialNumber())); // image URL
preg_match('/(.+)\?/',$resize_pic,$matches);
if($pictures[$count]['resized_picture'][0]){
array_push($pictures[$count]['resized_picture'],$matches[1]);
}
else{
$pictures[$count]['resized_picture'][0] = $matches[1];
}
//$pictures[$count]['resized_picture'] = $matches[1];
}
}
if($pictures[$count]['resized_picture'] == ""){
$pictures[$count]['resized_picture'] = $pictures[$count]['large_picture'];
}
$count++;
}
return $pictures;
}
?>