recent thumbnails

liquilife

Joined: 2005-09-10
Posts: 14
Posted: Mon, 2005-11-07 01:14

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.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-11-07 11:52

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

 
liquilife

Joined: 2005-09-10
Posts: 14
Posted: Mon, 2005-11-07 13:11

Thanks valiant for pointing that out. Looks like this is what I was after. :)

 
liquilife

Joined: 2005-09-10
Posts: 14
Posted: Mon, 2005-11-07 22:35

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!

 
liquilife

Joined: 2005-09-10
Posts: 14
Posted: Mon, 2005-11-07 23:07

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?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-11-08 00:25

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.

 
fabianv

Joined: 2007-08-17
Posts: 6
Posted: Fri, 2007-08-17 11:51

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

Quote:
Warning: main(/path/to/b/gallery/embed.php) [function.main]: failed to open stream: No such file or directory

require_once(dirname(__FILE__) . '/gallery/embed.php');
$ret = GalleryEmbed::init(array('fullInit' => true, 'embedPath' => '/gallery/'));

What do I do?