Find item thumbnail, resized photo, and imige size

insomnix

Joined: 2009-04-19
Posts: 24
Posted: Sun, 2009-10-04 23:16

I have an AddPhoto.inc that writes to an xml file the data I need for a java applet. There is a link under the photo that runs the below inc file and redirects back to the page I just left.

Everything works to write to my file, except I need additional information. I've tried the fetchThumbnailsByItemIds to help me get the thumbnial ID and have tried to use the generate url function, but I can't seem to get any of this to work. I've had fetchThumbnailsByItemIds working on another page, but not here, which makes me wonder if I'm not calling something I should be.

Below are my variables I am trying to write. I really could use some help finding the values for these.

Quote:
class AddPhotoController extends GalleryController {

function handleRequest($form) {
/* Check input. */
if (!is_numeric(GalleryUtilities::getRequestVariables('itemId'))) {

} else {
$picture_id=GalleryUtilities::getRequestVariables('itemId');

//Full size picture url
$high_res = "gallery/main.php?g2_view=core.DownloadItem&g2_itemId=".$picture_id;
//Title of picture
$title = "";
//Full size image size
$size = "";
//Full Size resolution width
$res_width = "";
//Full Size resolution height
$res_height = "";
//800x600 mid size image url
$screen = "";
//Thumbnail url
$thumb = "";

//Write variables to my xml file

}
$redirect = $status = $error = array();
$results['return'] = 1;
$results['redirect'] = $redirect;
$status = "Added to Tray";
$results['status'] = $status;
$results['error'] = $error;

return array(null, $results);
}
}

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2009-10-04 23:30
 
insomnix

Joined: 2009-04-19
Posts: 24
Posted: Sun, 2009-10-04 23:42

I've tried mediaBlock.php earlier. I get the below error when I copy the getThumbUrl to my inc file.

Quote:
Fatal error: Call to undefined function getThumbUrl()...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2009-10-05 00:13

did you copy the function?
or just the call for the function.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
insomnix

Joined: 2009-04-19
Posts: 24
Posted: Mon, 2009-10-05 00:14

I coppied the entire function and pasted above my function handleRequest($form).

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2009-10-05 00:29

so you called it like:

list($ret, $item) = GalleryCoreApi::loadEntitiesById($picture_id, 'GalleryItem');
    if ($ret) {
        print "Error loading item:".$ret->getAsHtml();
    }
list($thumbUrl, $thumbWidth, $thumbHeight) = AddPhotoController::getThumbUrl($item);

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
insomnix

Joined: 2009-04-19
Posts: 24
Posted: Mon, 2009-10-05 01:00

OK, that helped a lot. I am trying to generate the url for the full sized picture. I am using getView, but all it retrieves is "h".

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2009-10-05 01:14

with nearly every function in my script you need to pass an $item object which we loaded here: list($ret, $item) = GalleryCoreApi::loadEntitiesById($picture_id, 'GalleryItem');
you can pass the same object around to retrieve your desired output.

If you're trying to output an xml feed check function displayMediaRss

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
insomnix

Joined: 2009-04-19
Posts: 24
Posted: Mon, 2009-10-05 01:43

Thank you for your help, I've acomplished more in the last few hours than I have all day on this. I was looking through the list and did not find a function to get the file size. If you can point me in the right direction, I think I can write the function.

I also need to get an 800 x 600 view, and I saw the resize function, but I'm not sure how to make it work. Any thoughts?

Thanks again

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2009-10-05 02:05

hmmm... size I believe is simply $item->getSize(); from GalleryDataItem.
I don't believe that resize function is actually used, it returns a string of views, not what you want.
but function getBestImageId would.
you'd need to change:

if (isset($_REQUEST['g2_maxImageHeight'])) {
        $maxImageHeight = $_REQUEST['g2_maxImageHeight'];
    }
    if (isset($_REQUEST['g2_maxImageWidth'])) {
        $maxImageWidth = $_REQUEST['g2_maxImageWidth'];
    }

to:

        $maxImageHeight = 600;
        $maxImageWidth = 800;

and:

usort($potentialImages, "byWidth");

to:

usort($potentialImages, array('AddPhotoController', 'byWidth')););

and you would also need to include
function byWidth as well

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
insomnix

Joined: 2009-04-19
Posts: 24
Posted: Mon, 2009-10-05 04:08

Fantastic, that did it.

Thank you