title: Tumblr API v2: Displaying Images?
body: <p>I am trying to set up the Tumblr API on my site.</p>
  
  <p>So far I have text posts working fine like such:</p>
  
  <pre><code>$.ajax({
      url: "http://api.tumblr.com/v2/blog/myblog.tumblr.com/posts?api_key=myapikey",
      dataType: 'jsonp',
      success: function(results){
  
       var i = 0;
  
       while (i &lt; 20) {
  
         var type = results.response.posts[i].type;
         var date = results.response.posts[i].date;
  
         if (type == "text") {
           var title = results.response.posts[i].title;
           var content = results.response.posts[i].body;
           $("#myDivId").append("&lt;div class='posttitle'&gt;&lt;h2&gt;" + title + "&lt;/h2&gt;&lt;/div&gt;");
           $("#myDivId").append("&lt;div class='postbody'&gt;" + content + "&lt;/div&gt;");
         }
      i++;
       }//END WHILE
  
      }//END RESULTS FUNCTION
  });
  </code></pre>
  
  <p>But I cannot get the images to work. I know that, for whatever reason, images in a post are held within an array so I thought doing the following would suffice to get the first image:</p>
  
  <pre><code>   else if (type == "photo") {
           var photourl = results.response.posts[i].photos[0].url;
           $("#myDivId").append("&lt;div class='postbody'&gt;&lt;img src='" + photourl + "'/&gt;&lt;/div&gt;");
         }
  </code></pre>
  
  <p>But no avail. The Docs are here if anyone is interested: <a href="http://www.tumblr.com/docs/en/api/v2#photo-posts" rel="nofollow">http://www.tumblr.com/docs/en/api/v2#photo-posts</a></p>
  
  <p>Would anyone know how to get these images working? Thanks</p>