Last X images from an album

bvossey

Joined: 2007-08-19
Posts: 17
Posted: Sun, 2007-10-14 16:40

Hi everybody,

I just want to have the last X added images from an specified album. (where X is a number)

I checked the imageblock doc but imageblock is only for the whole gallery with recent|recent...
I also checked the G2Image Chooser code (thx capt_kirk!) but in this code, all items are parsed and then sorted.

There is no alternative to parse all the item and then sort it with a home function ?
Because, it seems to be something quite usefull but a lot of line to write...

Thanks for your help !

Benjamin

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2007-10-15 04:48

you can use the imageblock module for this just specify the g2_itemId of the album you want.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
bvossey

Joined: 2007-08-19
Posts: 17
Posted: Mon, 2007-10-15 07:19

Thanks floridave.

Indeed, i think the doc isn't very clear on this point but right, it's work ... but for the link on the images, I have the link to gallery element and I want to have the link to the real image (ie. jpg files). I checked the doc of getImageBlock and there is one parameter 'href' but I don't think I can do what I want ...

Output for one element :

Quote:
<div class="one-image">
<a href="http://www.mywebsite.com/v/essai/Athl__te.jpg.html">

<img src="http://www.mywebsite.com/gallery2/d/41-2/Athl__te.jpg" width="150" height="112" class="giThumbnail" alt="Athlète"/>
</a> </div>

Here is my code to have the last 3 images of an album:

Quote:
<?php
require_once 'gallery2/embed.php';
$ret = GalleryEmbed::init(array('fullInit' => true, 'embedUri' => '/', 'g2Uri' => '/gallery2/main.php'));
if ($ret) {
GalleryEmbed::done();
print 'Echec de la galerie: ' . $ret->getAsHtml();
exit;
}

list ($ret, $itemId) = GalleryCoreApi::fetchItemIdByPath('essai');
if ($itemId) {
list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(
array('blocks' => 'recentImage|recentImage|recentImage', 'itemId' => $itemId, 'show' => 'none'));
}
print $bodyHtml;

GalleryEmbed::done();

?>

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2007-10-15 13:47
Quote:
i think the doc isn't very clear on this point but right, it's work

Docs are written by the user for the user so feel free to make it more clear.

Quote:
I want to have the link to the real image (ie. jpg files)

The imageblock module does not have this switch. I think the 'href' parameter is for a custom link to what ever you like. I have never played with that so don't really know.
I guess you could make the <div> link to the image but wold take some coding to do.

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
bvossey

Joined: 2007-08-19
Posts: 17
Posted: Mon, 2007-10-15 14:37

How can i edit the API doc ? I did'nt find the 'edit' button.

Maybe i can have the path to the real image by another way than imageblock.
It seems that I will use/modify the code of capt_kirk in order to do that.

Thanks for your help

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2007-10-15 15:48
bvossey wrote:
How can i edit the API doc ?

Sorry I did not mean the API documentation I was thinking of the codex:
http://codex.gallery2.org/Gallery2:Modules:imageblock

Dave

_____________________________________________
Blog & G2 || floridave - Gallery Team