External Image Block for WP2
jbiljr
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. |
|
Posts: 1378
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
Posts: 10
Thanks ozgreg!
Yea I am kinda new to the WrodPress/Gallery thing so I was not sure if this info was known yet.
Posts: 11
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:
in the sidebar (with yoursite.com edited appropriately) but it doesn't load an image.
Does anyone have any advice on this?
Posts: 10
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
Posts: 11
Hi jbiljr
Thanks for your prompt, helpful feedback. I'll check out the codex.
Cheers,
Dan
Posts: 10
Hey Dan,
I apologize, but the link should have been codex.wordpress.org
Good Hunting,
Johnny