Tumblr api – Fullscreen backgrounds

For some reason, my blog database got rolled back a few months. I have no idea why, and neither does my hosting company. Grrr. Anyway, I was getting a few hits from people looking for the fullscreen background tumblr api post, so I thought I’d re-write it.

Here is the php code. It grabs the last 100 posts and puts them in an array, from which, a random image is selected and used as the background image.

<?php

// Load the Tumblr feed (photos only in this case) into a simplexml document
$url = "http://gomako.tumblr.com/api/read?type=photo&num=100";
$xml = simplexml_load_file($url);

// Loop through the images and add them to an array
foreach($xml--->posts-&gt;post as $post){
$bgImgs[] = $post-&gt;{'photo-url'}[0];
}

// Pick a random image out of the array.
$bgimg = $bgImgs[array_rand($bgImgs)];

// Get image width and height for script
list($imgwidth, $imgheight, $type, $attr) = getimagesize($bgimg);

?>

Now we need to pass the image details to the fullscreenr jQuery plugin. I have altered the script slightly to get it to work how I wanted. You can grab my copy here.

<!-- Load JQuery -->
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script><!-- Load the Fullscreenr plugin --><script type="text/javascript" src="js/jquery.fullscreenr.js"></script></code>

<script type="text/javascript">

// Specify the size of your background image here
var FullscreenrOptions = { width: <?php echo $imgwidth; ?>, height: <?php echo $imgheight; ?>, bgID: '#bgimg' };

// This will activate the full screen background!
jQuery.fn.fullscreenr(FullscreenrOptions);

</script>

Now you need to include this directly under the opening body tag

<!-- This is the background image -->
<img id="bgimg" src="<?php echo $bgimg; ?>"/>

That should be it!

Leave a Reply

Using Scriptogr.am Blog

I’ve just set up blog.gomako.co.uk to use scriptogr.am as a blogging platform, as I don’t really use wordpress to it’s full potential. I’ll be transferring these posts over at some point!

Sketchbooks

Sketchbook scans


I moved my sketchbook to a page that isn’t that obvious using this theme. While I try and find some time to make my theme better, the pages are here, here and here.

Tumblr api – Fullscreen backgrounds

For some reason, my blog database got rolled back a few months. I have no idea why, and neither does my hosting company. Grrr. Anyway, I was getting a few hits from people looking for the fullscreen background tumblr api post, so I thought I’d re-write it.

Here is the php code. It grabs the last 100 posts and puts them in an array, from which, a random image is selected and used as the background image.

<?php

// Load the Tumblr feed (photos only in this case) into a simplexml document
$url = "http://gomako.tumblr.com/api/read?type=photo&num=100";
$xml = simplexml_load_file($url);

// Loop through the images and add them to an array
foreach($xml--->posts-&gt;post as $post){
$bgImgs[] = $post-&gt;{'photo-url'}[0];
}

// Pick a random image out of the array.
$bgimg = $bgImgs[array_rand($bgImgs)];

// Get image width and height for script
list($imgwidth, $imgheight, $type, $attr) = getimagesize($bgimg);

?>

Now we need to pass the image details to the fullscreenr jQuery plugin. I have altered the script slightly to get it to work how I wanted. You can grab my copy here.

<!-- Load JQuery -->
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script><!-- Load the Fullscreenr plugin --><script type="text/javascript" src="js/jquery.fullscreenr.js"></script></code>

<script type="text/javascript">

// Specify the size of your background image here
var FullscreenrOptions = { width: <?php echo $imgwidth; ?>, height: <?php echo $imgheight; ?>, bgID: '#bgimg' };

// This will activate the full screen background!
jQuery.fn.fullscreenr(FullscreenrOptions);

</script>

Now you need to include this directly under the opening body tag

<!-- This is the background image -->
<img id="bgimg" src="<?php echo $bgimg; ?>"/>

That should be it!

Scary Pony

scaryPony

I had to make a mega cute logo for a client, and to counterbalance it and get the sickly taste out of my mind, I made a spoooooky version for halloween.

Tumblr account

So, I got myself a Tumblr account while I wait for my Dropular invite to arrive, so’s I can just bung crap out there that I haven’t done myself that I think is fancy pants.

Rock Poster Skeletal Ooze and Grog

ARJ Poster

So, my friends and neighbours are in a excellent band called Another Rhythm Jesus, and they asked me to make a poster for them, and gave me free range! Wheeeeee!

Some Processing…

I was put in touch with John Pett by my brother, Tom. John has a lot of lovely stuff on his site, and is interested in Processing. It rekindled my love of the little program, so I thought I’d start posting sketches, starting with this one (click the image to run the applet):

I Love Raid

Well, I re-installed everything on my macbook, and trawling through my backups, I found a picture I drew when I was hunting ants in an apartment in Spain. I was obsessed for the whole fortnight.

A long time since I last posted…

…so I thought I’d do a little colour sketch of a sketchbook scan. Hrmpf!

Spoonflower Fabric

Well, aaaages ago, Amy and I designed some fabric to be printed by Spoonflower that Amy was going to make into lovely quilts for our baby, Evie. Here some piccies, from design to realization! Woot.

The only fly in the ointment was our glorious government charging us AS MUCH AGAIN AS THE FABRIC COST IN IMPORT DUTY. Thanks guys.