Good afternoon,
My issues is fairly simple. I have a few PHP pages outside of gallery I'd like to include some recent thumbnails on. Is there a PHP snippet someone could share to simply grab the last x image thumbnails (linked to the image) added to a gallery2 setup?
Thanks, much appreciated! I've been searching for a solution with no luck.
Posts: 32509
you can use the external imageblock or GalleryEmbed::getImageBlock an call it with blocks=recentImage|recentImage|recentImage|recentImage|recentImage to get the 5 latest thumbnails.
see:
http://codex.gallery2.org/index.php/Gallery2:How_Tos#Image_Block
Posts: 14
Thanks valiant for pointing that out. Looks like this is what I was after.
Posts: 14
Ok, I've got it working great. How can I edit the manner in which the images are displayed? Right now each image is wrapped in a div. I want to simplify the html which is used to display the recent images and set them up to display horizontal instead of vertical. How could I do this? Thanks!
Posts: 14
Ok, I've got it all worked out. Here is the php I used:
<?php /* You'll have to change the /gallery2/ thing in the following 2 lines probably */ require_once(dirname(__FILE__) . '/gallery2/embed.php'); $ret = GalleryEmbed::init(array('fullInit' => true, 'embedPath' => '/gallery2/')); if ($ret->isError()) { print 'GalleryEmbed::init failed, here is the error message: ' . $ret->getAsHtml(); exit; } /* * See "Site admin" -> "image block" for all available options. the parameters are the same * as for the external imageblock */ list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'recentImage|recentImage|recentImage|recentImage|recentImage', 'show' => '')); if ($ret->isError()) { print 'GalleryEmbed::getImageBlock failed, here is the error message: ' . $ret->getAsHtml(); exit; } /* $bodyHtml contains the image block. print it somewhere on your website */ print $bodyHtml; /* * $headHtml is not required. if you use imageframes for your imageblocks, you need to print * $headHtml in the <head> section of your web page */ ?>I was then able to edit the .tpl file called ImageBlocks.tpl under modules > imageblocks > templates and strip out the div tags. Added a class to the link tag and some custom CSS. Viola, nicely formatted horizontal recent images.
This of course only worked because I am not using any image blocks in my gallery2 setup. I am assuming my template edits apply to any image blocks in gallery2 .. right?
Posts: 32509
yep, there are no separate templates for external imageblocks / getImageBlock imageblocks. you could change g2 to work like that. but right now there's a single template for all kinds of imageblocks.
Posts: 6
I'm a little confused.. I tried adding this to my wordpress but whenever I add the code I get the path added after the wordpress path, not replaced.
so..im getting the bold before the path
require_once(dirname(__FILE__) . '/gallery/embed.php');
$ret = GalleryEmbed::init(array('fullInit' => true, 'embedPath' => '/gallery/'));
What do I do?