Need help with extremely custom embed in ModX
theothermike
Joined: 2008-12-17
Posts: 2 |
Posted: Wed, 2008-12-17 17:04 |
Hello, I'm using Gallery2 inside ModX using a custom 'snippet' (ie. PHP code) to interface with the Gallery2 Database from within ModX. Currently, it executes some SQL against the g2_* tables to get a list of albums along with thumbnails, and a list of items inside the gallery, along with thumbnails. The query I came up with works great for the Album listing and even works ok for listing items in the albums. The problem comes when I use the gallery2 software to re-scale photos or add watermarks and such. I notice these become 'derivative' images, and I can't for the life of me come up with a single query that would account for this and return me the g2_itemId that corresponds to the latest derivative image. I'm hoping that someone here has more insight into the database and could provide me with an updated query that would do what I need. Below is the class and code I use to get the info from Gallery2 (relevant sections for brevity). Apologies in advance for style or PHP ignorance, I'm mainly a Perl developer this is the URL to display the photo of an image inside an album, this is where I can't get it to show the latest version. putting an & at the end at least shows the right size, but wont show the watermark
This method returns the actual g_id's of images inside the album (taking g_id of album as parameter). This must be the query that needs modification so it will return the g_id/serialNumber of the latest derivative image
Show the photos in the album here. Shows the thumbnails of the photos fine, but when I click on the generated link using $gal2_album_photos_url and the 'g_id' returned from getAlbumPhotoIds, it's not showing the latest version of the photo (re-scaled and watermarked)
To see it in action, the demo site is up at http://bn.mauvaisgarcons.net - and then click on 'Paparazzi'. The gallery2 url is http://bn.mauvaisgarcons.net/gallery2 |
|
Posts: 17
i was trying to do something very similar. this is the code that worked for me
$derivative_data = GalleryCoreApi::fetchResizesByItemIds(array($first_thumb_id));
$derivative_source_id = $derivative_data[1][$first_thumb_id][0]->id;
$derivative_serial_number = $derivative_data[1][$first_thumb_id][0]->serialNumber;
echo "<img src='/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=" . $derivative_source_id . "&g2_serialNumber=" . $derivative_serial_number . "' width>";
fetchResizesByItemIds returns an object with all the resized images data. from there you can hopefully find the one you need and act accordingly.
Posts: 2
Sweeet, thanks for the hint. I was able to get it to work properly by embedding the G2 completely using embed.php (before i was just hitting the database), and then calling
fetchThumbnailsByItemIds, and passing in the thumb id. From there I could access the object for that Item, and use the derivativeSourceId property to get it to show the latest version of the photo.