Get original photo of an album highlight
aymerick
Joined: 2005-11-30
Posts: 3 |
![]() |
Hi, I'm searching a simple way, given an album ID, to get the original photo of the album highlight. As far as i understand, I'm searching a way to: Is there already a simple function that does the job ? I haven't found. Thanks, |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
please don't post multiple topics for the same question. topic locked. edit: sorry, confused your username with another. the same question was asked twice today. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
GalleryCoreApi::fetchThumbnailsByItemIds to find the original photo: $sourceEntity can be either a GalleryPhotoItem or a GalleryDerivative $derivative->getParentId() returns the id of the album (the id for which this derivative is used). |
|
ruzster
Joined: 2006-05-30
Posts: 11 |
![]() |
I'm having trouble figuring this one out. I don't suppose someone could provide an example? Please? |
|
ruzster
Joined: 2006-05-30
Posts: 11 |
![]() |
Actually... nevermind. I think I got it. But now I'm getting this error: "Warning: Cannot use a scalar value as an array in <my directory>/gallery/modules/core/classes/GalleryPhotoItem.class on line 236" |
|
cc5henry
Joined: 2006-06-15
Posts: 12 |
![]() |
ruzster wrote:
Actually... nevermind. I think I got it. Did you adjust the code? Because it says <my directory> or is it just to not reveal ur domain? |
|
ruzster
Joined: 2006-05-30
Posts: 11 |
![]() |
Yes, I hid my domain. |
|
Umka
Joined: 2008-06-16
Posts: 12 |
![]() |
Greetings to all! Dear forum members, I encounter the same problem and can't solve it myself. I am making a theme for the Gallery2 (I use "tiny" installation) which supposed to behave this way: I click the root album thumbnail, then go to that album, then i click nested album thumbnail, but if album I clicked is the last one (no more nested albums detected), then I skip clicked "album" page, and go directly to the original image "photo" page, from which album thumbnail is made (highlighted image). Or, as an option, to the first item in that album, and again to the "photo" page, not album view. So I need to simply find item id which i would use in album thumbnail link, to skip album and go directly to the image. (Or as an option id of first item in clicked album) I decided to solve the "highlighted item link" problem first. I read topic above, and tried to modify my theme.inc, but when it came to this: Quote:
$sourceEntity = $derivative->getSourceId(); I stuck. I would appreciate any help on this, may be some source code. Thanks in advance and sorry for my English, it's my second. |
|
valiant
Joined: 2003-01-04
Posts: 32509 |
![]() |
- to decide whether the link should point to an album page or a photo page, you need to find out whether the album has any sub-albums. you can use GalleryCoreApi::fetchChildAlbumItemIds( ... ) in your theme.inc function showAlbumPage for that. if it returns more than 0 child albums for the id you're testing against, you can generate a link to an album page. else query for the album's highlight item to generate a link to that item's photo page. - to get the item id of the album's highlight, you need to do the following: - from the album itemId you get the album's thumbnail id (=highlight id): fetchThumbnailsByItemIds($albumId) do { list ($ret, $source) = GalleryCoreApi::loadEntitiesById($source->getDerivativeSourceId()); } while (GalleryUtilities::isA($source, 'GalleryDerivative')); if (GalleryUtilities::isA($source, 'GalleryItem') && $source->getParentId() == $albumId) { $itemIdForUrl = $source->getId(); } else { // fall back to the first child item of the album // e.g. use GalleryCoreApi::fetchChildIds() to get the album's children. } -------------- |
|
Umka
Joined: 2008-06-16
Posts: 12 |
![]() |
Thank you very much for your explanation. I'm starting to understand. I'm planning to end up with code that adds "thumbnailSourceId" variable to every "$children" array that contains thumbnails, and my major roadblock removed. I'll post my final result. |
|
Umka
Joined: 2008-06-16
Posts: 12 |
![]() |
Might be clumsy, but works for me. (Gallery 2.2.5) list ($ret, $thumbs) = GalleryCoreApi::fetchThumbnailsByItemIds($childIds); if ($ret) { return array($ret, null); } $counter = 0; foreach ($childIds as $child) { if ($theme['children']){ if ($theme['children'][$counter]['canContainChildren'] == 1) { list ($ret, $childEntity) = GalleryCoreApi::loadEntitiesById($child); list ($ret, $subChildren) = GalleryCoreApi::fetchChildItemIds($childEntity); if (count($subChildren) > 0 && $counter < count($thumbs)){ list ($ret, $derivativeThumbnailObject) = GalleryCoreApi::loadEntitiesById($thumbs[$child]->getDerivativeSourceId()); $theme['children'][$counter]['thumbnailSourceId'] = $derivativeThumbnailObject->getParentId(); } } } $counter++; } Thanks for help. P.S. Updated since my last post. |
|