Random Image from G2 in WP
-
Hello!
I have installed wordpress on my server and everything seems to be just fine. I used to run Serendipity, and there was a sidebar plugin that pulled 4 random images from a Gallery 2 install and placed them in the sidebar, along with a little information (title, views..).
I haven’t been able to find a very simple plugin or widget for WordPress that does this effectively. I am very well aware of the WPG2 plugin/widget bundle, but the host I have my website with is incapable of running one of the modules required to get it to work. Long story short, I only want the simplest feature of the thing, but it won’t run due to my webhost.
The Serendipity plugin called a module on the Gallery end of things called Random Block, so I don’t see why I couldn’t do the same with a little PHP in my sidebar and a PHP text widget (which I’ve got.) My WordPress install and Gallery are on two different subdomains, and the situation was the same with Serendipity and Gallery before.
I’ve seen plugin after plugin for WordPress which wraps Gallery in my WordPress template, but that’s not what I’m looking for. Does anyone have another suggestion or a bit of PHP they think might work? I’ve looked for days non-stop at this point, so this post is a last resort. This may be the DEAL BREAKER for WordPress.
Here’s some code suggested by Gallery 2’s website that may call on that random function. My problem with it is that the URL refrence
/gallery/embed. php
at the top of the code looks within the current subdomain and I can’t make it look elsewhere (another subdomain). For example, WP is installed in journal.x.com, and gallery is installed in gallery.x.com. This bit of code as is won’t look anywhere but its own subdomain, and I’m not sure how to modify it to do so.<?php
/* You'll have to change the /gallery2/ thing in the following 2 lines probably */
require_once(dirname(__FILE__) . '/gallery/embed.php');
$ret = GalleryEmbed::init(array('fullInit' => true, 'baseUri' => '/', 'g2Uri' => '/gallery/'));
if ($ret) {
print 'GalleryEmbed::init failed, here is the error message: ' . $ret->getAsHtml();
exit;
}
/*
* See "Site admin" -> "image block" for all available options. the parameters are the same
* as for the external imageblock
*/
list ($ret, $bodyHtml, $headHtml) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage',
'show' => 'title|date'));
if ($ret) {
print 'GalleryEmbed::getImageBlock failed, here is the error message: ' . $ret->getAsHtml();
exit;
}
/* $bodyHtml contains the image block. print it somewhere on your website */
print $bodyHtml;
/*
* $headHtml is not required. if you use imageframes for your imageblocks, you need to print
* $headHtml in the <head> section of your web page
*/
?>Incidentally, how old is the widgets functionality? It feels like it is fairly new, considering how few widgets have been created.
- The topic ‘Random Image from G2 in WP’ is closed to new replies.