Permalink
Browse files

Merge branch 'crawft'

Conflicts:
	flickr-conduit.js
  • Loading branch information...
2 parents 4709bae + 8161b45 commit f350edcd1a6f7b41e1d0b60edeaa85e2a0925fc4 @mncaudill committed Sep 12, 2012
Showing with 25 additions and 23 deletions.
  1. +25 −23 flickr-conduit.js
View
@@ -76,29 +76,31 @@ var parseFlickrPost = function(content, callback) {
var xml = new xml2js.Parser();
var imgObjs = [];
xml.on('end', function(data) {
- try {
- var entries = Array.isArray(data.feed.entry) ? data.feed.entry : [data.feed.entry];
- var imgData = null;
- var photoUrl= null;
- for (var i in entries) {
- imgData = entries[i]['media:content'][0]['$'];
-
- // Dumb, but there's a bug in the xml2js that messes up on the <link> tab. (Or I'm missing something.)
- var id = entries[i]['id'][0].split(':')[2].split('/')[2];
- photoUrl = entries[i].author[0].uri[0].replace("http://www.flickr.com/people/", 'http://www.flickr.com/photos/');
- photoUrl += id + '/';
-
- imgObjs.push({
- url: imgData.url,
- width: imgData.width,
- height: imgData.height,
- link: photoUrl,
- raw: entries[i],
- });
- }
- } catch (e) {
- // Noop
- }
+ try {
+ // We possibly get multiple entries per POST
+ var entries = Array.isArray(data.feed.entry) ? data.feed.entry : [data.feed.entry];
+
+ var imgData = null;
+ var photoUrl= null;
+ for (var i in entries) {
+ imgData = entries[i]['media:content'][0]['$'];
+
+ // Dumb, but there's a bug in the xml2js that messes up on the <link> tab. (Or I'm missing something.)
+ var id = entries[i]['id'][0].split(':')[2].split('/')[2];
+ photoUrl = entries[i].author[0].uri[0].replace("http://www.flickr.com/people/", 'http://www.flickr.com/photos/');
+ photoUrl += id + '/';
+
+ imgObjs.push({
+ url: imgData.url,
+ width: imgData.width,
+ height: imgData.height,
+ link: photoUrl,
+ raw: entries[i],
+ });
+ }
+ } catch (e) {
+ // Noop
+ }
callback(imgObjs);
});

0 comments on commit f350edc

Please sign in to comment.