API image display questions

undertoe
undertoe's picture

Joined: 2008-01-31
Posts: 32
Posted: Mon, 2008-02-18 20:50

I am completely stumped.

I am writing a theme and I have some scripts to kick back some xml responses for Ajax items.
All I am trying to do is get the a copy of the small image shown on this page:

http://colt45.chemlab.org/photos/main.php?g2_itemId=2498

I have used the fetchPreferredsByItemIds function but that does not always seem to give me the right image size.

example:
list ($ret, $preferred) = GalleryCoreApi::fetchPreferredsByItemIds( array( $child->getId() ) );

I want it so this page:
http://colt45.chemlab.org/photos/main.php?g2_itemId=2490

shows a 640x480 picture above the cover flow when an image is selected. Right now it shows the full size image.

This is driving me crazy, any help would be greatly appreciated.

 
undertoe
undertoe's picture

Joined: 2008-01-31
Posts: 32
Posted: Mon, 2008-02-18 21:48

Actually i think i may have gotten it. tell me if this code is the most effective use of the API

Quote:
list ($ret, $Ar_preferred) = GalleryCoreApi::fetchResizesByItemIds( array( $child->getId() ) );
foreach ($Ar_preferred[$MasterId] as $Row){
if($SavedSize > $Row->width || $SavedSize == 0)
$SavedSize = $Row->width;
$SavedSizeObj = $Row;
}

$preferedImg = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'href' => "/main.php", 'itemId' => $SavedSizeObj->getId(), 'serialNumber' => $SavedSizeObj->getSerialNumber() ));