HowTo: Use "Photowidget" by RoyTanck with G2

dreamingof8a

Joined: 2005-05-22
Posts: 66
Posted: Wed, 2009-08-05 13:02

Hey there,

just thought I might share some stuff I came up with recently.

Photowidget is a nice flash app to display images on your webpage. In combination with the external image block you can actually use it with your gallery. That's how I got it to work:

/* settings */
$g2_url = 'www.mygallery.com';              // url to main.php
$thumb_size = 60;                           // thumbnail size in pixel
$images = array ( 'randomImage'   => 12,    // number of types of images
                  'recentImage'   => 0,
                  'viewedImage'   => 0,
                  'randomAlbum'   => 0,
                  'recentAlbum'   => 0,
                  'viewedAlbum'   => 0,
                  'dailyImage'    => 0,
                  'weeklyImage'   => 0,
                  'monthlyImage'  => 0,
                  'dailyAlbum'    => 0,
                  'weeklyAlbum'   => 0,
                  'monthlyAlbum'  => 0,
                  'specificItem'  => 0 );


while( list ( $type, $count ) = each ( $images ) ) {
  for($i = 0; $i < $count; $i++) {
    $image_list .= $type . '|';
  }
}
$image_list = substr($image_list, 0, -1);   // get rid of trailing '|'

/* create source code */
$code = file_get_contents('http://' . $g2_url . '/main.php?g2_view=imageblock.External&g2_blocks=' . $image_list . '&g2_show=none&g2_maxSize='. $thumb_size .'&
g2_itemFrame=none');

/* regex rules */
$regex_image = '=^(.*)(<img|<image)(.*)src\="?(\S+)"([^>]*)>(.*)$=msi';
$regex_url = '=^(.*)(<a)(.*)href\="?(\S+)"([^>]*)>(.*)$=msi';

/* start creating xml content */
$xml = '<images>'. "\r\n";

while (preg_match($regex_url, $code, $finds_url) && preg_match($regex_image, $code, $finds_image)) { 
  $xml .= '<image href="' . $finds_url[4] . '">' . $finds_image[4] . '</image>' . "\r\n" ;
  $code = $finds_url[1];
}

$xml .= '</images>';

/* write xml file */
$file = fopen("photowidget.xml", "w");
fwrite($file, $xml);
fclose($file);

This piece of code only creates the required photowidget.xml, using pathnames from the external image block. You still have to embed the actual flash file acording to the instructions on the widgets homepage.

Maybe someone finds it useful.

Cheers,
Felix

Login or register to post comments
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 3133
Posted: Wed, 2009-08-05 13:10
Login or register to post comments
dreamingof8a

Joined: 2005-05-22
Posts: 66
Posted: Wed, 2009-08-05 14:56

See it in action here.

Login or register to post comments
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 3133
Posted: Wed, 2009-08-05 16:35

You could easily modify the xml generator found in my minislideshow to feed the PhotoWidget or even the feed generator in my SlideshowPro -> Gallery2 script.
It would lend the ability to display dynamic albums like tag albums or keyword albums as well as the usual types.

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

Login or register to post comments
dreamingof8a

Joined: 2005-05-22
Posts: 66
Posted: Wed, 2009-08-05 16:43

That's what I forst wanted to do. I tried after you had mentioned your script a while ago - but somehow I didn't quite understand where to start :-(
Might have a closer look again at some point

Felix

Login or register to post comments
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 10953
Posted: Wed, 2009-08-05 18:13

Thanks, added: http://codex.gallery2.org/Gallery2:User_Contributions#Mods.2FPatches
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

Login or register to post comments