<?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>Adam Bate &#187; phpflickr</title>
	<atom:link href="http://www.adambate.com/tag/phpflickr/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adambate.com</link>
	<description>Today is the best day of my life.</description>
	<lastBuildDate>Sun, 27 Jun 2010 21:12:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to add a Flickr-based photo gallery to your website: phpFlickr + Lightbox.</title>
		<link>http://www.adambate.com/2009/06/06/how-to-add-a-flickr-based-photo-gallery-to-your-website-phpflickr-lightbox/</link>
		<comments>http://www.adambate.com/2009/06/06/how-to-add-a-flickr-based-photo-gallery-to-your-website-phpflickr-lightbox/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 15:20:45 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpflickr]]></category>

		<guid isPermaLink="false">http://www.adambate.com/?p=195</guid>
		<description><![CDATA[Many people struggle with installing and setting up third-party gallery applications and although there are a couple popular image galleries that most web-hosts offer as an easy-to-install application, they can still be frustrating and pose many security issues for the inexperienced.
With the growing popularity of using Flickr to manage photos, more and more people are [...]]]></description>
			<content:encoded><![CDATA[<p>Many people struggle with installing and setting up third-party gallery applications and although there are a couple popular <a href="http://coppermine-gallery.net/">image</a> <a href="http://gallery.menalto.com/">galleries</a> that most web-hosts offer as an easy-to-install application, they can still be frustrating and pose many security issues for the inexperienced.</p>
<p>With the growing popularity of using <a href="http://www.flickr.com">Flickr</a> to manage photos, more and more people are looking for an easy way to display these photos on their website.</p>
<p>After some playing around, I&#8217;ve settled with the phpFlickr and Lightbox combination to nicely display photo galleries on a website. <a href="http://www.phpflickr.com">PhpFlickr</a> is a class written by Dan Coulter to act as a wrapper to Flickr&#8217;s API, and <a href="http://www.huddletogether.com/projects/lightbox/">lightbox</a> is a very simple and elegant way to display photos on a page. This tutorial will teach you how to quickly setup a photo gallery with phpflickr and lightbox on your own website.</p>
<h3>So what do you need?</h3>
<p>1. A flickr account (a free one with 100mb monthly upload is fine for most). You will also need to know your user ID (usually in the format xxxxxxxx@Nxx)</p>
<p>2. Latest version of phpflickr: can be <a href="http://code.google.com/p/phpflickr/downloads/list">downloaded here</a></p>
<p>3. Lightbox 2 java script: <a href="http://www.lokeshdhakar.com/projects/lightbox2/#download">downloaded here</a></p>
<p>4. Obviously, your photos.</p>
<h3>What to do:</h3>
<p>1. Upload the photos you want to display to your Flickr account. Organize the photos into Sets to best manage the separation of &#8220;galleries.&#8221;</p>
<p>2. Install phpFlickr and Lightbox by easily extracting them to the directory of your choice (ie. /photos/ on your website). Both phpFlickr and Lightbox are ready to go out-of-the-box so you won&#8217;t need to play around with them too much if you don&#8217;t want to.</p>
<p>3. Include the necessary content in your php file.</p>
<p>For lightbox, the following will go in the header section of your php file:</p>
<pre>
<code>&lt;script type="text/javascript" src="js/prototype.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"
          src="js/scriptaculous.js?load=effects,builder"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="js/lightbox.js"&gt;&lt;/script&gt;</code>
</pre>
<p>and</p>
<pre>
<code>&lt;link rel="stylesheet" href="css/lightbox.css"
     type="text/css" media="screen" /&gt;</code>
</pre>
<p>For phpFlickr, add the following code in the header section of your php file:</p>
<pre>
<code>&lt;?php
 require_once("phpFlickr/phpFlickr.php");
 $f = new phpFlickr("b16911dd0ec59f16ed66e80711edbdaf");
 $user = "xxxxxxxx@Nxx";
 $ph_sets = $f-&gt;photosets_getList($user);
?&gt;</code>
</pre>
<p>Where the user value can be found in your flickr account.</p>
<p>Now we are ready to use phpFlickr to import and Lightbox to display our pictures from our Flickr sets. Here&#8217;s a simple bit of code I use that imports and displays the photos:</p>
<pre>
<code>&lt;div id="gallery"&gt;
 &lt;?php foreach ($ph_sets['photoset'] as $ph_set): ?&gt;
  &lt;div class="photosets"&gt;
  &lt;p&gt;&lt;h2&gt;&lt;?php print $ph_set['title']; ?&gt;&lt;/h2&gt;&lt;/p&gt;
  &lt;?php $photoset_id = $ph_set['id'];
  $photos = $f-&gt;photosets_getPhotos($photoset_id);
  foreach ($photos['photoset']['photo'] as $photo): ?&gt;
  &lt;div class="photos"&gt;
   &lt;a rel="lightbox"
     href="&lt;?= $f-&gt;buildPhotoURL($photo, 'medium') ?&gt;"
     title="&lt;?= $photo['title'] ?&gt;"&gt;
   &lt;img src="&lt;?= $f-&gt;buildPhotoURL($photo, 'square') ?&gt;"
     alt="&lt;?= $photo['title'] ?&gt;" title="&lt;?= $photo['title'] ?&gt;" /&gt;
   &lt;/a&gt;
  &lt;/div&gt;
  &lt;?php endforeach; ?&gt;
  &lt;/div&gt;
 &lt;?php endforeach; ?&gt;
&lt;/div&gt;</code>
</pre>
<p>The CSS I use for this is:</p>
<pre>
<code>#gallery {
	position: relative;
	float: left;
	width: 600px;
	padding: 0px 15px 10px 15px;
}

.photos {
	position: relative;
	float: left;
	display: block;
	padding-bottom: 10px;
}
.photosets {
	clear: both;
	padding-top: 1px;
}
.photosets h2 {
	color: #000;
}</code>
</pre>
<p>The full documentation on both lightbox and phpFlickr is available in their downloaded packages. They are both quite powerful. The example given here is just a simple way to grab all the Sets in your Flickr account and display them in a gallery format.</p>
<p>I recently added this to the site <a href="http://www.designbyroeland.com/design-photos.php">designbyroeland.com</a>. You can check out the example of how it will look <a href="http://www.designbyroeland.com/design-photos.php">here</a>. Simple. Elegant.</p>
<p><strong>EDIT:</strong></p>
<p>If you&#8217;re looking to only display one set, this can be done with the following:</p>
<pre>
<code>&lt;?php $photos = $f-&gt;photosets_getPhotos('xxxxxxxxxxxxxxxxx'); ?&gt;
&lt;?php foreach ($photos['photo'] as $photo): ?&gt;
&lt;div class="photos"&gt;
&lt;a rel="lightbox" href="&lt;?= $f-&gt;
    buildPhotoURL($photo, 'medium') ?&gt;"
    title="&lt;?= $photo['title'] ?&gt;"&gt;
&lt;img src="&lt;?= $f-&gt;buildPhotoURL($photo, 'square') ?&gt;"
    alt="&lt;?= $photo['title'] ?&gt;" title="&lt;?= $photo['title'] ?&gt;" /&gt;
&lt;/a&gt;
&lt;/div&gt;
&lt;?php endforeach; ?&gt;</code>
</pre>
<p>Where the xxxx&#8217;s are replaced with the set ID that you can find in your flickr URL for that set. Feel free to republish this guide if you wish, but please try to link back if possible. Thanks!</p>
<div style="text-align:center; margin:0px auto;">
<script type="text/javascript"><!--
google_ad_client = "pub-0251857145152151";
/* phpflickr link */
google_ad_slot = "9646689994";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.adambate.com/2009/06/06/how-to-add-a-flickr-based-photo-gallery-to-your-website-phpflickr-lightbox/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
	</channel>
</rss>
