Thursday, December 11, 2008

Embed Picasa albums in your own site

Recently I spent some significant time looking for a way to embed online photo albums into the North Dakota Junior Chamber website. There was a great option called PictoBrowser if our hosting service had been flickr. However as we already use an embedded Google calendar it made much more sense for us to be using the Google alternative Picasa.

Try as I might, I could not find a widget or script to pull Picasa albums and photos. So I wrote my own. It's not pretty, and pure php so no fancy java or anything. But it pulls the xml from Picasa and embeds everything inside our website. For now I'm happy.



<?php

/*** Variables *************************************************************************************/
$user = 'juspar'; //user account name
$thumbsize = '160c'; //possible values:
//32, 48, 64, 72, 144, 160 with a 'u' uncropped or 'c' cropped suffix
//200, 288, 320, 400, 512, 576, 640, 720, 800 only uncropped, no sufix necessary
$outputsize = '512'; //possible values:
//200, 288, 320, 400, 512, 576, 640, 720, 800
/*******************************************************************************************************/

if($photo)
{
// build photos feed URL
$urlFeed = "http://picasaweb.google.com/data/feed/api/user/$user/album/$album?thumbsize=$outputsize";

// read feed into SimpleXML object
$sxml = simplexml_load_file($urlFeed);

foreach ($sxml->entry as $entry)
{
// get nodes in media: and gphoto: namespace
$media = $entry->children('http://search.yahoo.com/mrss/');
$gphoto = $entry->children('http://schemas.google.com/photos/2007');

//read thumbnail attributes
$attribs = $media->group->thumbnail[0]->attributes();

//assign url attribute to variable
$thumbnail = $attribs['url'];

//assign photo id variable
$gphotoid = $gphoto->id;

//asign photo caption to a variable
$caption = $entry->summary;

//output match
if($gphotoid==$photo)
{
echo"<p class='photo'><a href='http://picasaweb.google.com/$user/$album#$photo' target='_blank'>"
."<img src='$thumbnail' alt='$caption' /><br />$caption</a></p>";
}
}
}

if ($album)
{
//build album feed URL
$urlFeed = "http://picasaweb.google.com/data/feed/api/user/$user/album/$album?thumbsize=$thumbsize";

// read feed into SimpleXML object
$sxml = simplexml_load_file($urlFeed);

// get album names and number of photos in each
foreach ($sxml->entry as $entry)
{
// get nodes in media: and gphoto: namespace
$media = $entry->children('http://search.yahoo.com/mrss/');
$gphoto = $entry->children('http://schemas.google.com/photos/2007');

//read thumbnail attributes
$attribs = $media->group->thumbnail[0]->attributes();

//assign url attribute to variable
$thumbnail = $attribs['url'];

//assign photo id variable
$photo = $gphoto->id;

echo "<p class='thumbnail'><a href='../index.php?type=guest&page=photos&user=$user&album=$album&photo=$photo'>"
."<img src='$thumbnail' alt='' border=0 /></a></p>";
}
}
else
{
//build albums feed URL
$urlFeed = "http://picasaweb.google.com/data/feed/api/user/$user?kind=album&thumbsize=$thumbsize";

// read feed into SimpleXML object
$sxml = simplexml_load_file($urlFeed);

// get album names and number of photos in each
foreach ($sxml->entry as $entry)
{
// get nodes in media: and gphoto: namespace
$media = $entry->children('http://search.yahoo.com/mrss/');
$gphoto = $entry->children('http://schemas.google.com/photos/2007');

//assign variables from xml
$album = $entry->title;
$attribs = $media->group->thumbnail[0]->attributes();
$thumbnail = $attribs['url'];
$numphotos = $gphoto->numphotos;

//tidy up album names for link
$albumlink = str_replace(" ","",$album);
$albumlink = strtolower($albumlink);

echo "<p class='thumbnail'><a href='../index.php?type=guest&page=photos&user=$user&album=$albumlink'>"
."<img src='$thumbnail' alt='$album' border=0 /><br />$album<br />$numphotos photo(s)</a></p>";
}
}
?>

Wednesday, January 3, 2007

What to say

I play games because real life is hard. I play games because they are fun. I play games because it's one of the few places I'm in control. I play games because the feedback is limited to a small window, and not a buzz of overpowering noise that invades my skull. I play games because I can analyse their rules and understand them, and work within them knowing exactly what to expect. I play games because there I can succeed.

The Daedalus Project - Addiction

Monday, October 23, 2006

Google Video time wasters

The things you find out there in cyber space. This is from The Jaime Kennedy Experiment.

Thursday, October 19, 2006

Expressions

Sometimes I'm overwhelmed, I don't know how to show you just how I feel.

I want to make tender passionate love to you.

On a beautiful four posted solid oak bed, with freshly laundered white linens.

In the middle of a meadow, with a river running through it.

Then write a soul wrenching ballad about the experience.

And play it on a mountain top, with full symphonic orchestral backing.

As I step out of my skin and blaze with pure light.

Then rain down like a monsoon that will cover the world.

There are not words, deeds, or any other expression to show you the strength and depth of my love, sometimes I feel like I'm going to explode because I can't release it.

But what can I do? I look at you with emotion brimming in my eyes, and you think I'm upset. Then I fall back on the three most over used words in the english language . . . I love you.

Wednesday, October 4, 2006

To every girl

I found this on a friends Blog, it certainly applealed to me. I'd like to be the kind of guy that makes this girl happy.

To every girl that dresses cute, not skanky.


To every girl who wants to be called beautiful, not hot.


To every girl that will spend her whole day looking for the perfect present for you.


To every girl who gets her heart broken, because he chose that bitch instead


To every girl that would die to have a decent boyfriend.


To every girl who would just once like to be treated like a princess.


To every girl that cries at night because of another heartbreak.


To every girl that won't get down on her knees and open her mouth just to get a boyfriend.

To every girl that just wants to hold hands.


To every girl that kisses him with meaning.


To every girl who just wishes he cared more.


To every girl who would just once want a guy to give their jacket up when they are cold.


To every girl who just wants him to call.


To every girl who lies awake at night thinking about him.


To every girl that just wants to cuddle.


To every girl that just wants to sleep with him without having sex.


To every girl that is SCARED to put her heart out there again, because she has been HURT too many times or so badly.


To every girl who shows how much she cares and gets nothing back.


To every girl that thought 'maybe this one could be the one'.


To every girl that laughs at stupid stuff when she actually doesn't think it is funny.


To every girl who is just looking for that one and only and is having a rough time along the way.


To every girl that has been cheated on, because she's not a slut who gives it up to any guy.


To every girl that doesn't want a guy who just plays with her emotions but actually cares about how she feels.

To every girl who wants words backed up with actions.


To every girl that fell for all the lies only to find themselves alone in the end.


To every girl that gave her heart away to have it shoved back in her face.

To every girl that has faith that 'tomorrow will be a better day.'

It will be.

Friday, September 22, 2006

Hindsight is 20:20

I never knew there was a clue. But of course there was.

It wasn't long ago that Crysta asked me to download some songs. When I started working I coppied all my music to the work computer to listen to. Sitting in my office, brought to tears by my own foolish blindness I listened to this:

"I miss my friend
The one my heart and soul confided in
The one I felt the safest with
The one who knew just what to say to make me laugh again
And let the light back in
I miss my friend"

Wednesday, September 20, 2006

rat a tat tat
the machinegun rattle
of the keyboard
from the next room
I love you, I love you , I love you
ten thousand little needles
leave me broken and bleeding