External Image Block for WP2

jbiljr
jbiljr's picture

Joined: 2005-12-25
Posts: 10
Posted: Fri, 2006-05-12 16:48

Hey all,

I had been scouring the forums for a solution to an external image block link problem I was having. It was related to linking an image back to the embedded Gallery in WordPress. The link kept returning the image in the stand-alone Gallery install I had on my server.

I did find this post which I thought was related but it seems that is was not:

External Image Block link problem

So I continued my search and could not find a solution. So with a little hacking I found a very simple solution to the problem and wanted to share it. I am not sure if this has been brought to attention yet, and if it has I did not find it on this forum.

The little hacking I did lead me to try the simplest change in the External Image code.

The existing External Image code looks like this:

<?php @readfile('http://www.yoursite.com/gallery2/main.php?g2_view=imageblock:External&g2_blocks=randomImage&g2_show=title'); ?>

You have to place this in your external page in order to have one of your images appear, and in this example it is a random image. The problem is that when you click on the image it brings you to the stand-alone Gallery.

If you have Gallery embedded into Wordpress this becomes a problem because it takes you out of the WP environment. In order to counter act this simply place the link to your wp-gallery2.php page into the above string like this:

?php @readfile('http://www.yoursite.com/wp-gallery2.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title');
?>

It is that easy. Now when a user clicks on the linked image it brings them to that image embedded in your WordPress.

Like I said this may be a repeat of someone else’s post, or it could be that it is so damn simple that you all figured it out on your own. Either way I could not find the answer here, so I posted my solution in the hopes that others find it useful.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Wed, 2006-05-24 11:32

Thanks for the post, I am not sure if you are aware but Wordpress WPG2 plugin does all this and more

Wordpress Gallery2 Plug-in Downloads, Documentation & Support Gallery Embedded Community Site

 
jbiljr
jbiljr's picture

Joined: 2005-12-25
Posts: 10
Posted: Wed, 2006-05-24 12:55

Thanks ozgreg!

Yea I am kinda new to the WrodPress/Gallery thing so I was not sure if this info was known yet.

 
divulge
divulge's picture

Joined: 2006-02-01
Posts: 11
Posted: Mon, 2006-06-19 22:54

I haven't embedded my G2 into Wordpress, instead I have them both installed on completely different domains.

That said, I wish to include the random image thumbnail in the sidebar of my wordpress install. I have placed the code:

Quote:
<?php @readfile('http://www.yoursite.com/gallery2/main.php?g2_view=imageblock:External&g2_blocks=randomImage&g2_show=title'); ?>

in the sidebar (with yoursite.com edited appropriately) but it doesn't load an image.

Does anyone have any advice on this?

 
jbiljr
jbiljr's picture

Joined: 2005-12-25
Posts: 10
Posted: Tue, 2006-06-20 01:04

Hey divulge,

You have to have the PHP libraries for Gallery running on the server that you want to display the image on. If they are seperate then it will not work. You can try and link the image dynamicaly but then it will not be random. There are plugins available for Wordpress that will display random images on your home page. Check out the Wordpress codex for more infoe on that. codex.wordpress.com

jbiljr

 
divulge
divulge's picture

Joined: 2006-02-01
Posts: 11
Posted: Tue, 2006-06-20 01:58

Hi jbiljr

Thanks for your prompt, helpful feedback. I'll check out the codex.

Cheers,
Dan

 
jbiljr
jbiljr's picture

Joined: 2005-12-25
Posts: 10
Posted: Tue, 2006-06-20 02:50

Hey Dan,

I apologize, but the link should have been codex.wordpress.org

Good Hunting,

Johnny