Random Image Block php code for WordGallery

kinchyle

Joined: 2009-03-08
Posts: 11
Posted: Fri, 2009-07-24 15:41

I'd like to add the piece of php that grabs a random image from the gallery.
I'd like to then add the code to my Wordpress Gallery sidebar.

Anyone have a direction for files to look into or code to grab.
I've found the module code but can't seem to piece it.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2009-07-24 15:46

There is no ImageBlock module for gallery3 yet.
but you can try the minislideshow.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
kinchyle

Joined: 2009-03-08
Posts: 11
Posted: Sat, 2009-07-25 02:19

Oh wow! Nice work. This is exactly what I've been looking for.
I've been trying RSS parsers and image gallery loaders from disk all with no luck.
This IS a wordpress plugin.
Here is the code i just added to the sidebar.php template for Wordpress "Edit Themes".
It pulls in all my "Newly Added" and gives the slideshow a link to the root of the gallery.
I couldn't figure out how to get the individual image to go the correct one in the gallery. It was a little off on mine.

<div id="G3Mini"><a href="/gallery3/index.php" target="_blank">Your Gallery</a></div>
<script type="text/javascript" src="/gallery3/swfobject.js"></script> <script type="text/javascript">
// <![CDATA[
var so = new SWFObject("/gallery3/minislideshow.swf", "minislideshow", "320", "240", "9.0.115.0", "ffffff");
so.addParam("flashVars","xmlUrl=/gallery3/index.php/rss/feed/gallery/latest&useResizes=true&showDropShadow=true&delay=5&useFull=false&roundedMask=true&linkTarget=_blank&altLink=/gallery3/index.php");
so.addParam("wmode","transparent");
so.addParam("allowFullscreen","true");
so.addParam("allowScriptAccess","always");
so.write("G3Mini");
// ]]>
</script>

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sat, 2009-07-25 02:56
Quote:
I couldn't figure out how to get the individual image to go the correct one in the gallery

altLink(alternate) replaces the individual links, so just remove that.
not sure how you were able to use useResizes=true and useFull=false you cannot use resizes without using the full. So you are using the thumbs. Maybe my embed-o-rator needs some adjustment.

If you decide to have multiple minis on one page you simply need to make sure you have different <div id="G3Mini"> & so.write("G3Mini");

Glad it helped you.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
kinchyle

Joined: 2009-03-08
Posts: 11
Posted: Tue, 2009-07-28 19:37

This keeps getting better. Didn't realize there was an embed-o-rator. I just pieced mine together.
I'll run it and get the parameters correct.
I wanted to use thumbnails for speed of load and since it was small on the sidebar the thumbnails sufficed.
I thought the useResize would expand/contract the thumbnails to use the full 320x240.

 
kweik
kweik's picture

Joined: 2006-06-02
Posts: 2
Posted: Wed, 2009-09-23 16:13

but,, with this only see the lastest photos,,,

its possible a same concept but with a random image??

thanks!

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Wed, 2009-09-23 17:37

I don't think G3 currently has a random image rss feed.(yet)

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
nkinkade

Joined: 2009-12-05
Posts: 37
Posted: Sat, 2009-12-05 04:05

I just created a very small, quick and dirty module that will return a random image wrapped in an anchor tag when you visit a URL like /index.php/randimg. I am using it at the following URL. If you refresh the page the image will change:

http://natha.nkinka.de

There is a tiny bit of code on that index page:

<?php
$imglink = file_get_contents("http://natha.nkinka.de/photos/index.php/randimg", "r");
echo "$imglink";
?>

You can view/download the code here:

http://code.nkinka.de/gitweb?p=randimg.git;a=summary

You'll need to edit a bit of the code to suit your needs, specifically modules/randimg/views/randimg.html.php.

No warranties, but it seems to be working for me.

Nathan

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Mon, 2009-12-07 00:26

Nathan,
Thanks for your contribution.
Please create a new thread with your module.
Could the stuff you hardcoded for your url be a php/G3 variable so the user does not have to edit files?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
nkinkade

Joined: 2009-12-05
Posts: 37
Posted: Sun, 2010-01-03 19:59

Done: http://gallery.menalto.com/node/93574

... and I believe that there should be no need to edit the code now. Actually, I had corrected that just a few minutes after posting here. It now all relies on Apache variables to reconstruct the proper URL for the site where the module is installed.

I'm also curious about this:

http://github.com/gallery/gallery3/commit/b8ee6f25bdd9372dccd4552ca29cf6f2857e8164

Will that commit obviate the need for the randimg module?

Thanks,

NaThan