Skip to content

Instantly share code, notes, and snippets.

@rmoch
Created September 13, 2017 18:06
Show Gist options
  • Save rmoch/a449e34bc620717bd4acfd4a410c8bce to your computer and use it in GitHub Desktop.
Save rmoch/a449e34bc620717bd4acfd4a410c8bce to your computer and use it in GitHub Desktop.
parseArticlesAttachments: function() {
for (var idx1 = 0; idx1 < this.state.articles.length; idx1++) {
var item = this.state.articles[idx1];
if (item.source === 'feed') {
if (item.attachments) {
for (var idx2 = 0; idx2 < item.attachments.data.length; idx2++) {
var att = item.attachments.data[idx2];
console.log('*****', att.type)
if (att.type === 'album') {
console.log('title ', att.title)
console.log('link to FB ', att.url)
for (var idx3 = 0; idx3 < att.subattachments.data.length; idx3++) {
var subatt = att.subattachments.data[idx3];
if (subatt.type ==='photo') {
console.log('photo ' + idx3, subatt.media.image.src)
} else {
console.log('----', subatt.type)
}
}
} else if (att.type === 'photo') {
console.log('photo ', att.media.image.src)
// console.log('description ', att.description) // duplicate article content
} else if (att.type === 'video_inline') {
console.log('thumbnail ', att.media.image.src)
console.log('title ', att.title)
console.log('link to FB ',att.url)
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment