<?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>Elliott Media Group</title>
	<atom:link href="http://elliottmediagroup.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://elliottmediagroup.com</link>
	<description>EMG</description>
	<lastBuildDate>Sun, 08 Apr 2012 02:21:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Hello world!</title>
		<link>http://elliottmediagroup.com/2011/11/27/hello-world/</link>
		<comments>http://elliottmediagroup.com/2011/11/27/hello-world/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 07:13:39 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://elliottmediagroup.com/wp/?p=1</guid>
		<description><![CDATA[Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!]]></description>
			<content:encoded><![CDATA[<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottmediagroup.com/2011/11/27/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>News Corp. Launches &#8220;The Daily&#8221; iPad Publication</title>
		<link>http://elliottmediagroup.com/2011/02/03/news-corp-launches-the-daily-ipad-publication/</link>
		<comments>http://elliottmediagroup.com/2011/02/03/news-corp-launches-the-daily-ipad-publication/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 04:36:42 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://elliottmediagroup.com/?p=157</guid>
		<description><![CDATA[In a world where print media is slowly receding into the shadows of new technology, it is clear that tablets devices are going to rule the future. Rupert Murdoch has obviously realized this with his launch of &#8220;The Daily,&#8221; a brand new news experience for the iPad. I have a had a chance to take [...]]]></description>
			<content:encoded><![CDATA[<p>In a world where print media is slowly receding into the shadows of new technology, it is clear that tablets devices are going to rule the future. Rupert Murdoch has obviously realized this with his launch of &#8220;The Daily,&#8221; a brand new news experience for the iPad. I have a had a chance to take a look at the product, and I would share some thoughts and screenshots on some key areas of the experience.<span id="more-157"></span></p>
<h2>The Basics</h2>
<p>You can access The Daily by downloading it onto the iPad through the App Store. A new &#8216;issue&#8217; is published every morning, and will download automatically. Prices are very impressive, at $0.99 a week or $39.99 a year, which works out at a hare over 14 cents a day. The publication is going to be free for the next two weeks due to a sponsorship by Verizon, so you can try it out at no cost.</p>
<h2>Content</h2>
<p>The biggest benefit of having a news publication on the iPad is the ability publishers have to take advantage of the rich experience the device allows. In my experience of the first issue of The Daily, I have found some beautiful photos, well made videos, and interesting stories. The Daily is also able to pull in Twitter feeds relative to stories and allows users to follow links out to websites. Nifty animations accompany all of this rich content.</p>
<ul style="list-style:none">
<li style="float:left; display:block;"><a rel="prettyPhoto" style="; display:block; margin-right:10px; width:100px" href="http://elliottmediagroup.com/wp-content/uploads/2011/02/content.PNG"><img src="http://elliottmediagroup.com/wp-content/uploads/2011/02/content.PNG" style="width:100px;  ;/"></a></li>
<li style="float:left; display:block;"><a rel="prettyPhoto" style="; display:block; margin-right:10px; width:100px" href="http://elliottmediagroup.com/wp-content/uploads/2011/02/content%202.PNG"><img src="http://elliottmediagroup.com/wp-content/uploads/2011/02/content%202.PNG" style="width:100px;"></a></li>
<li style="float:left; display:block;"><a rel="prettyPhoto" style="; display:block; margin-right:10px; width:100px" href="http://elliottmediagroup.com/wp-content/uploads/2011/02/cover%20story.PNG"><img src="http://elliottmediagroup.com/wp-content/uploads/2011/02/cover%20story.PNG" style="width:100px; /"></a></li>
<li style="float:left; display:block;"><a rel="prettyPhoto" style="; display:block; margin-right:10px; width:100px" href="http://elliottmediagroup.com/wp-content/uploads/2011/02/cover%202.PNG"><img src="http://elliottmediagroup.com/wp-content/uploads/2011/02/cover%202.PNG" style="width:100px; /"></a></li>
<li style="float:left; display:block;"><a rel="prettyPhoto" style="; display:block; margin-right:10px; width:100px" href="http://elliottmediagroup.com/wp-content/uploads/2011/02/photograph.PNG"><img src="http://elliottmediagroup.com/wp-content/uploads/2011/02/photograph.PNG" style="width:100px; /"></a></li>
</ul>
<div style="clear:both"></div>
<p><br/></p>
<h2>User Interface</h2>
<p>The app features several ways to navigate through content, perhaps the &#8216;prettiest&#8217; is the carousel view that allows you to swipe through various sections of the publication. You can tap on stories to view them full screen, and then swipe left and right to go between pages. The app also features rotation of the device to reveal special content such as landscape photography. Upon first use, I found a very slight learning curve to getting around, but within ten or so minutes it felt very natural and easy to use.</p>
<ul style="list-style:none">
<li style="float:left; display:block;"><a rel="prettyPhoto" style="; display:block; margin-right:10px; width:100px" href="http://elliottmediagroup.com/wp-content/uploads/2011/02/carousel.PNG"><img src="http://elliottmediagroup.com/wp-content/uploads/2011/02/carousel.PNG" style="width:100px;  ;/"></a></li>
<li style="float:left; display:block;"><a rel="prettyPhoto" style="; display:block; margin-right:10px; width:100px" href="http://elliottmediagroup.com/wp-content/uploads/2011/02/navigation.PNG"><img src="http://elliottmediagroup.com/wp-content/uploads/2011/02/navigation.PNG" style="width:100px;"></a></li>
</ul>
<div style="clear:both"></div>
<p><br/></p>
<h2>Advertising</h2>
<p>Many who see that The Daily requires a subscription may argue that advertising is unnecessary and even greedy on the part of News Corp.. I don&#8217;t want to play fan boy to Murdoch, but I must say I think the advertising is warranted in the app. You see ads in your local print newspaper, and you still pay a price for that (which in fact is much more per issue than the weekly cost of The Daily). I did not find the ads annoying or obnoxious, and some were even fun and engaging. Many of the ads feature interactive elements or videos, which make them very bearable and even fun!</p>
<ul style="list-style:none">
<li style="float:left; display:block;"><a rel="prettyPhoto" style="; display:block; margin-right:10px; width:100px" href="http://elliottmediagroup.com/wp-content/uploads/2011/02/ad.PNG"><img src="http://elliottmediagroup.com/wp-content/uploads/2011/02/ad.PNG" style="width:100px;  ;/"></a></li>
</ul>
<div style="clear:both"><br/></p>
<h2>Closing Thoughts</h2>
<p>As we head full steam into the second decade of the millenium, it is clear that the world of Journalism and media formats is being shaken, twisted, rearranged, and refined to match the typical consumer of the day. The Daily is News Corp&#8217;s first and bold foray into the world of tablet news consumption, and I believe it is a worthy and exciting veture that I am sure will change the lanscape for news publishers.</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottmediagroup.com/2011/02/03/news-corp-launches-the-daily-ipad-publication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating County Overlays with Google Maps Javascript API</title>
		<link>http://elliottmediagroup.com/2011/01/24/maps-api/</link>
		<comments>http://elliottmediagroup.com/2011/01/24/maps-api/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 07:45:13 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://elliottmediagroup.com/?p=137</guid>
		<description><![CDATA[I am working with a client that wanted a feature on their website where users could find the nearest sales rep to their location. The client&#8217;s company have several sales reps that represent various counties in Southern California. I began working on using the awesome Google Map API to create such a tool, and it [...]]]></description>
			<content:encoded><![CDATA[<p>I am working with a client that wanted a feature on their website where users could find the nearest sales rep to their location. The client&#8217;s company have several sales reps that represent various counties in Southern California. I began working on using the awesome Google Map API to create such a tool, and it will be launched soon.</p>
<p>As I worked on the tool, I learned a lot, and I wanted to share some of my new-found knowledge with everyone. In the following post (including a video, yay!) I will show you how to create a county overlay on a Google Map.</p>
<p><span id="more-137"></span></p>
<h2>The Video</h2>
<p>You can watch a video of me explaining everything below. In it I explain things in more detail.<br />
<iframe title="YouTube video player" class="youtube-player" type="text/html" width="600" height="480" src="http://www.youtube.com/embed/jlJmiFUxv6c?rel=0" frameborder="0" allowFullScreen></iframe></p>
<h2>The Basics</h2>
<p>To see the final product we are aiming for, <a href="http://elliottmediagroup.com/subdomains/playground/maps%20v3/index.php">click here</a>.<br />
To begin, we need to initialize the Maps API with the following:</p>
<pre class="prettyprint">&lt;script src="http://maps.google.com/maps/api/js?sensor=true"&gt;&lt;/script&gt;</pre>
<p>The &#8220;?sensor=true&#8221; parameter tells the API whether it should try and take advantage of any GPS sensors that might exist on the device accessing the map. We won&#8217;t be using this function, but its not a bad thing to include for the future.</p>
<p>Next, we need to embed a map on our page. We can do this by making the following function and firing it using the body onload method.</p>
<pre class="prettyprint">function loadMap(){

	var myOptions = {
			zoom: 9,
			center: new google.maps.LatLng(34.0522,-118.2437),
			mapTypeId: google.maps.MapTypeId.TERRAIN
		};

	var map = new google.maps.Map(document.getElementById("map"), myOptions);

}
</pre>
<p>This code sets zoom, center, and type parameters for the map and then creates the map by targeting an element with an id of &#8220;map&#8221; (in this case we used a div).</p>
<h2>Getting County Area Data</h2>
<p>The Maps API has not function to automatically create overlays in the shape of state counties. It can, however, take a set of LatLng coordinates and create a polygonal overlay. After a little Googling. I came across the <a href="http://www.census.gov/geo/www/cob/" target="_blank">U.S. Census Bureau Cartographic Boundary Files</a>. They give you nicely organized lists of coordinate areas of every county in America (and a ton of other boundary types, like school districts, voting areas, and zip codes). The only problem is that the data isn&#8217;t ready for the Maps API.</p>
<p>To convert it, I went through of series of steps involving find and replace, spreadsheet manipulation, and the terminal. It sounds confusing and long, but its still a pretty straightforward process. For the textual examples, I have used only a few datapoints to conserve space. Below is a flowchart of the steps:</p>
<p style="text-align:center">
<img src="https://docs.google.com/drawings/pub?id=1d9TnL1kUFcrvl8YD_jbFQhSL3FyxMszPmVQizhIy5f8&amp;w=500" alt="" /></p>
<h2>Using the Data</h2>
<p>Phew! Now we have the data in a usable form, it&#8217;s time to store it in our code. The best way to do this is to create an external file called data.js and input the data into it as a variable with the name rawData, like so:</p>
<pre class="prettyprint">var rawData =" 42.0038450000000,123.230762000000;42.0054460000000,123.192361000000;42.0080360000000,123.154908000000;";</pre>
<p>Don&#8217;t forget to include this file in your page header. Next, we need to iterate through the data and create an array of LatLng objects. We will do this in a function called createOverlay():</p>
<pre class="prettyprint">function createOverlay(){

				var overlayCoords = new Array();

				var processedData = rawData.split(";");

				for (var i=0; i
<processedData.length; i++){

					var xyCoords = processedData[i].split(",");

					overlayCoords.push(new google.maps.LatLng(xyCoords[0],xyCoords[1]));

				}

				var myOverlay = new google.maps.Polygon({

					paths: overlayCoords,
					strokeColor: "#FF0000",
		   			strokeOpacity: 0.8,
		    		strokeWeight: 2,
		    		fillColor: "#FF0000",
		    		fillOpacity: 0.35

				});

				return myOverlay
			}</pre>
<p>This code splits the data into array elements by searching for semicolons. It then takes each element of the new array and splits it again into latitude and longitude by finding the comma. The coordinates are stored in a new google.maps.LatLng object and pushed onto an array called overlayCoords. This array is then parsed to a new google.maps.Polygon</pre>
<p> object along with some other parameters. This object is returned out of the function.</p>
<h2>Putting it All Together</h2>
<p>Now we have our function for creating overlays, we can fire it by placing the following two lines of code in the loadMap function after the map is created.</p>
<pre class="prettyprint">var laCounty = createOverlay();
laCounty.setMap(map);</pre>
<p>This code creates a variable called laCounty that is set equal to the overlay created by the createOverlay function. The variable is then placed on the page. The results look something like this:</p>
<p><a href="http://elliottmediagroup.com/wp-content/uploads/2011/01/Screen-shot-2011-01-23-at-11.03.13-PM.png" rel="prettyPhoto"><img src="http://elliottmediagroup.com/wp-content/uploads/2011/01/Screen-shot-2011-01-23-at-11.03.13-PM.png" alt="" title="Google Maps Overlay" width="500" class="aligncenter size-full wp-image-147" /></a></p>
<h2>Adding a Clear Function</h2>
<p>v3 of the Google Maps API has not easy way to clear overlays on a map. This is somewhat of a pain, especially if you are going to display multiple county overlays in one session. The good news is there is a relatively simple workaround. Every time you place an overlay on the map, push it onto a special array to keep track. When you want to clear the map, iterate through the overlay array placing each element on the map as null (essentially deleting it). Finally clear the overlay array to start fresh. If it sounds confusing, watch the video as I explain it and show its use with a nice button.</p>
<h2>Finishing Up</h2>
<p>I hope this has been helpful for someone out there! If you would like to view a live example of this all in action, <a href="http://elliottmediagroup.com/subdomains/playground/maps%20v3/index.php">click here</a>. Let me know in the comments if you have any questions or ideas on things you would like me to explain in the future!</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottmediagroup.com/2011/01/24/maps-api/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Display PDFs Inline with A Little Help From Google&#8230;</title>
		<link>http://elliottmediagroup.com/2011/01/20/inline-pdfs-with-google/</link>
		<comments>http://elliottmediagroup.com/2011/01/20/inline-pdfs-with-google/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 02:57:28 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://elliottmediagroup.com/?p=125</guid>
		<description><![CDATA[Ahh the PDF. The gold standard of document exchange and sharing, PDFs are one of the most commonly used filetypes today. But they have a drawback when it comes to the web. Unlike image files (JPEG, GIF, TIFF, PNG, etc.), you can&#8217;t easily display a PDF inline with HTML on a website. &#8220;Why is this [...]]]></description>
			<content:encoded><![CDATA[<p>Ahh the PDF. The gold standard of document exchange and sharing, PDFs are one of the most commonly used filetypes today. But they have a drawback when it comes to the web. Unlike image files (JPEG, GIF, TIFF, PNG, etc.), you can&#8217;t easily display a PDF inline with HTML on a website. &#8220;Why is this a problem?&#8221; I hear you ask. Suppose you want to show project spec sheets in a web portfolio, or show a resume on a personal site. You can&#8217;t use a PDF without converting each page to an image and then displaying them all on your page. With a little help from Google, however, the process becomes a whole lot easier.<br />
<span id="more-125"></span><br />
As you may or may not know, Google has a very popular service called <a href="http://docs.google.com" target="_blank">Google Docs</a>, a cloud based document processing suite a la MS Office on the web. As part of the service, you can upload files (including PDFs) and have them saved in your document library. When you want to view one of your files, you can just click and see it instantly. No downloading, no nonsense. Google pull off the trick of displaying PDFs on web pages using their own special tool. This tool takes the file you upload and displays it using some fancy Javascript.</p>
<p>It turns out you can take this technology found in Google Docs (and other areas of Google for that matter) and use it on your own site by embedding the converter tool in an iFrame. The code below demonstrates this:</p>
<pre class="prettyprint">&lt;iframe src="http://docs.google.com/gview?url=http://elliottmediagroup.com/PATH_TO_PDF.pdf&amp;embedded=true" frameborder="0"&gt;&lt;/iframe&gt;</pre>
<p>This simple chunk of code generates the following result:</p>
<p>	<iframe src="http://docs.google.com/gview?url=http://elliottmediagroup.com/subdomains/playground/pdf-display/sample%20pdf.pdf&#038;embedded=true" style="width:100%; height:680px;" frameborder="0"></iframe></p>
<p>So all you have to do is include this iFrame with the path to your PDF (which you could dynamically generate using a ton of techniques) and voila, you have a PDF displayed on your page! You can of course style up the frame with width and height and other attributes. Its a pretty sweet solution!</p>
<p>I don&#8217;t want to take credit for coming up with this technique all by my lonesome. I found a <a href="http://stackoverflow.com/questions/291813/best-way-to-embed-pdf-in-html" target="_blank">great thread</a> on <a href="http://stackoverflow.com" target="_blank">StackOverflow</a> where people had this exact issue, and someone came up with this great solution. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottmediagroup.com/2011/01/20/inline-pdfs-with-google/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easily Make Full Page Screenshots with webkit2png</title>
		<link>http://elliottmediagroup.com/2011/01/16/webkit2png/</link>
		<comments>http://elliottmediagroup.com/2011/01/16/webkit2png/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 21:06:17 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Tools and Apps]]></category>

		<guid isPermaLink="false">http://elliottmediagroup.com/?p=118</guid>
		<description><![CDATA[As a web developer and designer, I am always taking screenshots of web pages. Sometimes I do this to show a client something, other times I just need a shot for my portfolio. But there&#8217;s a problem&#8230; One of the most annoying things about using OSX&#8217;s built in screenshot tool is that there is no [...]]]></description>
			<content:encoded><![CDATA[<p>As a web developer and designer, I am always taking screenshots of web pages. Sometimes I do this to show a client something, other times I just need a shot for my portfolio. But there&#8217;s a problem&#8230;</p>
<p><span id="more-118"></span></p>
<p>One of the most annoying things about using OSX&#8217;s built in screenshot tool is that there is no easy way to grab content from a webpage that goes beyond &#8216;the fold&#8217;; the area you have to scroll to see in your browser. The only way to do this is to take two or more screenshots, stich them together in Photoshop, and then save the result. That&#8217;s a time consuming process that is anything but efficient!</p>
<p>Enter webkit2png. This is a command line tool that allows you grab full page screenshots without the labor of stitching. I know its command-line based, but don&#8217;t let that scare you; it&#8217;s really easy to use. You just download one file from the <a href="http://www.paulhammond.org/webkit2png/" target="_blank">developer&#8217;s website</a> and then run the following line of code:</p>
<pre class="prettyprint"><code>python /path/to/webkit2png.txt.sh http://thedomainyouwanttocapture.com</code></pre>
<p>That&#8217;s it. webkit2png will connect to the site, figure out its dimensions, and generate a png for you. It also by default will generate a thumbnail image (very useful for portfolio galleries) and a clipped thumbnail (useful if you want all your thumbnails in a portfolio to have the same dimensions).</p>
<p>This is a simple solution for an all-to-common problem. Thank you very much, <a href="http://paulhammond.org" target="_blank">Paul Hammond</a>, for this awesome tool!</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottmediagroup.com/2011/01/16/webkit2png/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mac App Store Thoughts</title>
		<link>http://elliottmediagroup.com/2011/01/06/mac-app-store-thoughts/</link>
		<comments>http://elliottmediagroup.com/2011/01/06/mac-app-store-thoughts/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 15:52:25 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://blog.elliottmediagroup.com/?p=42</guid>
		<description><![CDATA[While I normally like to write about web development, I do have an interest in software development as well. Today, Apple unveiled their much-touted Mac App Store, an online store similar to the App Store found on the iPhone and iPad. I thought I would share some of my thoughts on the new location for [...]]]></description>
			<content:encoded><![CDATA[<p>While I normally like to write about web development, I do have an interest in software development as well. Today, Apple unveiled their much-touted Mac App Store, an online store similar to the App Store found on the iPhone and iPad. I thought I would share some of my thoughts on the new location for downloading apps.<br />
<span id="more-105"></span></p>
<h3>A Single App</h3>
<p>It is interesting that the Mac App Store is a single, standalone application. It is not rolled into iTunes, but rather is more like the App stores found on the iPad and iPhone. I believe this decision to make the app standalone is a deliberate move by Apple to bridge the gap between portable i-devices and computers, a connect they hinted would grow strength with the next major version of OSX, <a href="http://www.apple.com/macosx/lion/" target="_blank">Lion</a>.</p>
<p>It is also cool that Apple bundled the store in an OSX update. This instantly creates a large userbase for Apple developers to target, much like how iPhone and iPad developers can target every user with one of those devices.</p>
<h3>Pricing</h3>
<p>One of the things I am very excited about in the new Mac App Store is the pricing of applications compared to their counterparts found in brick-and-mortar stores or on developer websites. Pixelmator, the popular image editor is just $29.99 on the App Store, if you walk into an Apple Store the purchase will set you back $59.99. Here&#8217; a big one: Aperture 3, the big daddy to Apple&#8217;s iPhoto application, costs just $79.99 on the App Store, on Amazon.com or at an Apple store is costs $199.99! Thats a 60% savings!</p>
<p>Apple have also made their popular iLife and iWork Application suites available on a per-application basis. This means you can purchase just iPhoto or iMovie, or just Numbers or Keynote, without having to purchase the whole suite. Each iLife application costs $14.99, which means you actually save five bucks over buying the suite in its entirety (you do lose the iWeb and iDVD applications however if you go the App Store route). iWork applications cost $20 each, which means you undercut the suite by almost another $20 by buying the apps individually.</p>
<h3>Ease of Use</h3>
<p>I can already tell the Mac App Store is going to cost me a lot of money, because it is so easy to download applications! It works almost identically to purchasing an app on the iPhone; you click &#8220;install&#8221; and you instantly see the app appear in your dock with a progress bar overlaid. That&#8217;s it. There&#8217;s no dragging and dropping like traditional app installs. I can definitely see the store being used by novice users as it provides a simple and easy way to tap into the rich world of Mac software.</p>
<h3>Closing Thoughts</h3>
<p>All in all, I think Apple has done a great job with their latest release. The Mac App Store is going to change the world of Mac software, just like the iPhone changed mobile development. It is going to be very exciting to see how thing progress!</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottmediagroup.com/2011/01/06/mac-app-store-thoughts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display Flickr Feeds with JSON and Javascript</title>
		<link>http://elliottmediagroup.com/2010/12/12/display-flickr-feeds-with-json-and-javascript/</link>
		<comments>http://elliottmediagroup.com/2010/12/12/display-flickr-feeds-with-json-and-javascript/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 07:22:30 +0000</pubDate>
		<dc:creator>Elliott</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.elliottmediagroup.com/?p=9</guid>
		<description><![CDATA[I have recently been working on a project for a client that required an image gallery component. The images that were to be used in the gallery were in a set on Flickr. I had two options on displaying the images: Download and re-upload each image to a directory on the project website (long, tedious, [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been working on a project for a client that required an image gallery component. The images that were to be used in the gallery were in a set on <a href="http://flickr.com">Flickr</a>. I had two options on displaying the images:</p>
<ul>
<li>Download and re-upload each image to a directory on the project website (long, tedious, and inefficient)</li>
<li>Pull the images in live from Flickr (dynamic and efficient)</li>
</ul>
<p>I had a problem, however: I had no idea how to pull images live from Flickr. However, I had recently begun learning JavaScript, and wanted to put my new skills to the test. I began to research&#8230;<br />
<span id="more-104"></span><br />
It turns out Flickr support a method of data-interchange called JSON (JavaScript Object Notation) which basically allows you to send a URL to Flickr with a request of the data you want, and then receive a response back that you can process into html. Let me show you.</p>
<p>The first thing you need to do is obtain a Flickr API key. While this isn&#8217;t necessary for all the different URLs you can send to Flickr, it definitely opens you up to a lot of functionality. You can get one for free <a href="http://www.flickr.com/services/api/" target="_blank">here</a>.</p>
<p>Next, you need to decide what you want to display from Flickr on your page. In the example below, I have a URL that will return my Flickr Photo Feed.</p>
<pre class="prettyprint">http://api.flickr.com/services/rest/?format=json
&amp;api_key=xxx&amp;method=flickr.people.getPublicPhotos
&amp;user_id=24309165@N05&amp;per_page=50&amp;page=1
&amp;jsoncallback=jsonFlickrLoadUserStream</pre>
<p>Let&#8217;s break down the parameters of the URL:</p>
<ul>
<li><strong>?format =json</strong> simply returns a JSON formated feed</li>
<li><strong>&amp;method = flickr.people.getPublicPhotos</strong> is the way we will access the Flickr API. There are tons of ways you can access the API, you can check them out <a title="Flickr API" href="http://www.flickr.com/services/api/" target="_blank">here</a>.</li>
<li><strong>&amp;user_id</strong> is a required parameter of the method we are using. Different methods require different parameters. To find out the user id for a particular username, you can use the wonderful <a title="ID Gettr" href="http://idgettr.com" target="_blank">idgettr.com</a> tool.</li>
<li><strong>&amp;per_page</strong> is a optional parameter that will default to 100 if omitted. It tells Flickr how many items to return in the JSON feed. The maximum allowed per page is 500. Make sure not to set the value to more than the number of items you are trying to call, for example don&#8217;t set it to 500 if you only have 200 items in your feed.</li>
<li><strong>&amp;page</strong> is another optional parameter that represents the page of results you want returned. This is handy if you want to display more than 500 results because you can send a second URL request for the second page of results.</li>
<li><strong>&amp;api_key</strong> is your api key, which is required for this method.</li>
<li><strong>&amp;jsoncallback</strong> is the name of the function you will write in JavaScript to process the feed.</li>
</ul>
<p>To send this request on your page, create a &lt;script&gt; element with the src attribute set to the API call, like this:</p>
<pre class="prettyprint">&lt;script src="http://api.flickr.com/services/rest/?format=json
&amp;method=flickr.people.getPublicPhotos&amp;user_id=24309165@N05
&amp;per_page=50&amp;page=1&amp;api_key=xxx
&amp;jsoncallback=jsonFlickrLoadUserStream"&gt;&lt;/script&gt;</pre>
<p>You can also type the url directly into your web browser to make sure you are getting a response. I found this to be a handy way to check for errors when my code didn&#8217;t work.</p>
<p>Next up is processing the api call and displaying meaningful results on your page. There are a million different ways to do this, but I am going to show you the way that worked for me. You can of course place the code inline in your page or link to it externally, whatever works for you is fine. What is important is that you have the function name match the one specified in the jsoncallback parameter of the url. Below is the entire code I used. I will break each part down individually after.</p>
<pre class="prettyprint">function jsonFlickrLoadUserStream(rsp) {
	if (rsp.stat != "ok") return;

	var picture_wall = '';

	var photoCount = rsp.photos.perpage;

		for(var i = 0; i &lt; photoCount; i++) {

			var photo = rsp.photos.photo[i];

			var img_src = "http://farm" + photo.farm + ".static.flickr.com/" + photo.server + "/" + photo.id + "_" + photo.secret + "_" + "s.jpg";

			var a_href = "http://www.flickr.com/photos/" + photo.owner + "/" + photo.id + "/";

			picture_wall += '&lt;div style="width:50px; height:50px; float:left; overflow:hidden"&gt;';

			picture_wall += '&lt;a  href="' + a_href + '" target="_blank" &gt;';

			picture_wall += '&lt;img id="img_' + i + '" src="' + img_src + '" width=50 style="border-width:0px; border-style:none;" /&gt;&lt;/a&gt;rn';

			picture_wall += '&lt;/div&gt;';

		}

			picture_wall += '&lt;div style="clear:both; width:100%"&gt;&lt;/div&gt;';

	document.getElementById("imagestream").innerHTML = picture_wall;

}
</pre>
<p>The code begins by declaring a function called jsonFlickrLoadUserStream with an input called &#8216;rsp&#8217;. It then checks to see the status of the JSON feed returned, and returns if the feed doesn&#8217;t come in properly.</p>
<pre class="prettyprint">function jsonFlickrLoadUserStream(rsp) {
	if (rsp.stat != "ok") return;</pre>
<p>We then define a variable called &#8220;picture_wall&#8221; which will hold the output of the feed that we want to display on the page. We also define a variable called &#8220;photoCount&#8221; and set it equal to the perpage attribute.</p>
<pre class="prettyprint">var picture_wall = '';

var photoCount = rsp.photos.perpage;</pre>
<p>Now is a good time to discuss how you access particular parts of a JSON feed. A JSON feed consists of elements nested within members nested in an object. To access a particular member, you must define the &#8216;path&#8217; to that member. In the case of the &#8216;perpage&#8217; element, we can see by looking at the feed that it is housed within the photos member of the feed (you can see this if you look at the url response in your web browser). Because of this, the &#8216;path&#8217; to the element is rsp.photos.perpage. We will be accessing other elements in much the same way.</p>
<p>Next we begin a for loop to loop through the photos in the JSON feed.</p>
<pre class="prettyprint">for(var i = 0; i &lt; photoCount; i++) {

			var photo = rsp.photos.photo[i];</pre>
<p>The loop will run equal to the number of items in the feed, which is where the photoCount variable comes in. We then create a variable called &#8216;photo&#8217; that we set equal to an array element found in the photos member of the feed (rsp.photos.photo[i]). This element is an array because there is more than one photo in the feed. We are only interested in the current photo on each iteration of the for loop, so we set it equal to our counter (i).</p>
<p>Next, we set variables for the image source and link to the image page on Flickr.</p>
<pre class="prettyprint">var img_src = "http://farm" + photo.farm + ".static.flickr.com/" + photo.server + "/" + photo.id + "_" + photo.secret + "_" + "s.jpg";

var a_href = "http://www.flickr.com/photos/" + photo.owner + "/" + photo.id + "/";</pre>
<p>The JSON feed does not provide a full URL element for the image source, so we have to build it ourselves using the photo.farm, photo.server, photo.id, and photo.secret elements. Bear in mind these elements are actually found at the rsp.photos.photo member, but that we set a variable called &#8216;photo&#8217; to rsp.photos.photo[i] to make things easier to type. the &#8220;s.jpg&#8221; part of the variable is interesting. Flickr provide several sizes of photos, each of which is denoted by a one-letter name. These are the names they use:</p>
<ul>
<li>O = orignial size (only available for pro accounts)</li>
<li>B = big (1024px on biggest side on available for pro accounts)</li>
<li>Z = medium (640px on biggest side)</li>
<li>M = medium (500px on biggest side)</li>
<li>S = small (240px on biggest side)</li>
<li>T = thumbnail (100px on biggest side)</li>
<li>SQ = square (75px by 75px)</li>
</ul>
<p>We also set a link back to the photo on Flickr. This is required by Flickr&#8217;s terms of service; you can&#8217;t pull photos without providing a means for a visitor to find them back on Flickr.</p>
<p>Next comes placing the image and link on the page.</p>
<pre class="prettyprint">picture_wall += '&lt;div style="width:50px; height:50px; float:left; overflow:hidden"&gt;';

			picture_wall += '&lt;a  href="' + a_href + '" target="_blank" &gt;';

			picture_wall += '&lt;img id="img_' + i + '" src="' + img_src + '" width=50 style="border-width:0px; border-style:none;" />&lt;/a&gt;';

			picture_wall += '&lt;/div&gt;';</pre>
<p>While it isn&#8217;t completely necessary, I create a div element first to place the image in. I set the &#8216;overflow&#8217; property to &#8216;hidden&#8217;. This means that I can display vertical images in a horizontal container without messing up the flow of, say, an image gallery. Be sure to set the width and height properties of the div and img elements to match the size of your images.</p>
<p>Next we finish things up:</p>
<pre class="prettyprint">
picture_wall += '&lt;div style="clear:both; width:100%"&gt;&lt;/div&gt;';

	document.getElementById("imagestream").innerHTML = picture_wall;

}</pre>
<p>We added a float element to the end of all the images because this stops things below the gallery from breaking or appearing in weird places. Finally, we insert the &#8216;picture_wall&#8217; object to a div with an id of &#8220;imagestream.&#8221; You could of course set this to any div on the page.</p>
<p>That&#8217;s all there is to it. I am happy I was able to figure out how this worked, and I must give credit to my friend <a href="http://jamesyeary.com">James Yeary</a>, who helped make everything work. Thanks James!</p>
<p>I hope this tutorial helps you out with your web design and development projects. If you have questions, bugs, or problems, be sure to let me know in the comments below!</p>
]]></content:encoded>
			<wfw:commentRss>http://elliottmediagroup.com/2010/12/12/display-flickr-feeds-with-json-and-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

