Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling Images in Text Posts Using Tumblr API
    text
    copied!<p>I'm using the Featured Posts Plugin created by Bandit Design (<a href="http://blog.bandit.co.nz/post/87511743/tumblr-featured-posts-javascript-plugin" rel="nofollow">http://blog.bandit.co.nz/post/87511743/tumblr-featured-posts-javascript-plugin</a>) and I'd like to include the images from text posts in the list of featured posts (which will actually just be a single post, the image with the post title below it, if you were wondering). The problem is that the Tumblr API doesn't include a parameter for photos within text posts (you can call the entire body of the post, but that's not ideal here). The depth of my Javascript knowledge could be described as "enough to somehow get things to work, but more likely just break things", so the solution is probably fairly obvious here and I'm just missing it.</p> <p>The code I have right now:</p> <pre><code>/* TUMBLR FEATURED POSTS SCRIPT Automatically gets all posts tagged with "featured" and lists them REQUIRES JQUERY! -------------------------------------- Created by james &lt;at&gt; bandit.co.nz http://blog.bandit.co.nz Some code borrowed from Jacob DeHart's AJAX Search: http://blog.bandit.co.nz/post/80415548/tumblr-ajax-inline-search */ Featured = { 'apiNum' : 50, // how many posts to read 'listId' : '_featured', // the id of the ul to write to 'tagName' : '_featured', // the name of the tag we're searching for 'linkAppend' : '', // html to append to the end of each linked post 'postDB' : [], 'listPos' : 0, 'doList' : function (where) { var li; var ul = $('#'+where); var titles = {"link":"link-text", "photo":"photo-caption", "quote":"quote-text", "regular":"regular-title", "video":"video-caption"} // cycle through post database pcount = Featured.postDB.length; for(i=Featured.listPos;i&lt;pcount;i++) { p = Featured.postDB[i]; if(p[titles[p.type]] != '') titlestr = p[titles[p.type]].replace(/&lt;\/?[^&gt;]+&gt;/gi, ''); else titlestr = p['url']; li = document.createElement('li'); $(li).html('&lt;a class="'+p.type+'" href="'+p["url-with-slug"]+'"&gt;'+p["regular-body"]+titlestr+Featured.linkAppend+'&lt;/a&gt;'); ul.append(li); Featured.listPos = pcount; } }, 'getData' : function() { $.get('/api/read/json?num='+Featured.apiNum+'&amp;tagged='+Featured.tagName, function(data) { eval(data); for(i=0;i&lt;tumblr_api_read.posts.length;i++) { Featured.postDB.push(tumblr_api_read.posts[i]); Featured.doList(Featured.listId); } } ); } }; $(document).ready(function(){ Featured.getData(); }); </code></pre> <p>Any help would be much appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload