[SOLVED] Embedding a specific image into a Drupal node

MichelleC

Joined: 2005-04-16
Posts: 42
Posted: Fri, 2005-09-16 20:15

I've been trying to figure out the code I need to take an image from G2 and embed it into my Drupal blog. I started out finding the "readfile" code, but the link it creates goes to stand alone G2. After some searching, I found out that I can't use that in this thread: http://gallery.menalto.com/node/28526 .

So I tried to adapt the code I found there to:

require_once('/gallery2/embed.php');
global $user;
$ret = GalleryEmbed::init(array('embedUri' => 'index.php?page=photos',
   'embedPath' => '/gallery2',
   'relativeG2Path' => '/gallery2',
   'loginRedirect' => '',
   'activeUserId' => $user->uid); 
list ($ret, $imageBlockHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage', 'show' => 'title'));
GalleryEmbed::done();

But I've got something wrong because all I get is:

Parse error: parse error, unexpected ';' in /home/user/public_html/drupalsites/includes/common.inc(1857) : eval()'d code on line 8

Has anyone done this? Can you see what I have wrong? I'm guessing it's something in the paths, so here is my setup:

Drupal codebase: /home/user/public_html/drupalsites
Drupal site: /home/user/public_html/drupalsites/sites/example.com
G2 codebase: /home/user/public_html/gallery2
G2 site: /home/user/public_html/drupalsites/sites/example.com/gallery2

The base domain, www.example.com points to /home/user/public_html/drupalsites

Any ideas?

Thanks,

Michelle

[edit: Changed my website to example.com because I decided I didn't want my personal website archived here forever. :) ]

 
MichelleC

Joined: 2005-04-16
Posts: 42
Posted: Sat, 2005-09-17 15:14

Valiant helped me through this on IRC, so I'm posting a follow-up summary in case anyone else needs the answer.

The error was that I was missing a closing paren after "$user->uid)". But my paths were also wrong and it was missing 'fullInit' => true.

The corrected code looks like this (you need to change the paths to your own):

require_once('/home/user/public_html/drupalsites/sites/example.com/gallery2/embed.php');
global $user;
$ret = GalleryEmbed::init(array('embedUri' => './gallery/index.php?page=photos',
   'embedPath' => '/',
   'relativeG2Path' => './gallery',
   'loginRedirect' => '',
   'fullInit' => true,
   'activeUserId' => $user->uid)); 
list ($ret, $imageBlockHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'specificItem', 'show' => 'none', 'itemId' => ID NUMBER GOES HERE, 'itemFrame' => 'slide'));
GalleryEmbed::done();

That will put the HTML in $imageBlockHtml so you need to print or echo that out.

For the image frames to work, you need this in the HTML (change the * to brackets):

*link rel="stylesheet" href="http://example.com/sites/example.com/gallery2/main.php?g2_controller=imageblock.ExternalCSS&g2_frames=slide"/*

The thumbnail size will be whatever it's set to in the album. You should be able to add "'maxSize' => 300" but there is a bug so it's not working yet. (see https://sourceforge.net/tracker/index.php?func=detail&aid=1293856&group_id=7130&atid=107130 )

I'm working on writing a Drupal module to make it so all you have to do is put [G2:item_id] in your node and it will run the code. I got it working in a hard coded hacky way that I'm willing to share if there's interest. I plan to keep at it and get a proper module, but that may be some weeks away. So if you're in a hurry, let me know and I'll post the hacky way.

Michelle