G2.1 and ImageBlock embedding

zeguigui

Joined: 2006-01-31
Posts: 4
Posted: Thu, 2006-03-30 23:32

Hello,

I just migrated to G2.1 from G2.0... to discover that embedding changed a little. Only 3 parameters, great!

I use embedding to display a random image on my blog main page :
http://www.zeguigui.com/weblog

My Gallery is there:
http://www.zeguigui.com/photos

I use URL Rewriting (apache mod_rewrite).

The code I use to display a random block :

<?php
   require_once("../gallery2/embed.php");
   $ret = GalleryEmbed::init(
              array( 'embedUri' => '../photos/index.php',
                     'g2Uri'    => '/photos/',
                     'fullInit' => 'true'));
					
	list ($ret, $imageBlockHtml) = GalleryEmbed::getImageBlock( array(
						'blocks'  => 'randomImage',
						'show'    => 'title',
						'maxSize' => 170));
	echo $imageBlockHtml;
	GalleryEmbed::done();
?>

With this code it's almost correct.
If i use g2Uri = /gallery2/ then the src part of the random image is /gallery2/d ?!

There is also a problem with the generated link... it links to "v/%path%" whereas it should link to "/photos/v/%path%" (prefixed with website URL if necessary).

I did not have this problem with G2.0 with this init :

$ret = GalleryEmbed::init(
     array(
       'embedUri' => 'index.php',
       'fullInit' => 'true',
       'embedPath' => '/photos',
       'relativeG2Path' => '../gallery2',
       'loginRedirect' => '',
       'activeUserId' => ''));

Any hint on how I can have both link and img src correct?

Thanks
Guillaume

 
zeguigui

Joined: 2006-01-31
Posts: 4
Posted: Thu, 2006-03-30 23:45

OK... found the solution!
Should have read the documentation a little bit deeper and the new integration notes
http://codex.gallery2.org/index.php/Gallery2:Integration_Howto#New_.28Gallery_2.1.29_Specs_for_GalleryEmbed::init.28.29

Solution is to remove embedUri:

Quote:
If not specified, G2 generates URLs based on the current REQUEST_URI and its default baseFile 'main.php'. If the rewrite module is active, URLs are generated based on the stored embeddedLocation.

Note: as there is no static content I can also remove g2Uri :-)