From 4824ab30cafe088b0cb6c047650eec9212561e9d Mon Sep 17 00:00:00 2001 From: stockmind Date: Fri, 30 Mar 2018 20:23:47 +0200 Subject: [PATCH 1/2] Add post.attachment_url to all the social networks objects --- js/jquery.socialfeed.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/js/jquery.socialfeed.js b/js/jquery.socialfeed.js index 546e543..ac2eab2 100644 --- a/js/jquery.socialfeed.js +++ b/js/jquery.socialfeed.js @@ -290,6 +290,7 @@ if (typeof Object.create !== 'function') { if (element.entities.media && element.entities.media.length > 0) { var image_url = element.entities.media[0].media_url_https; if (image_url) { + post.attachment_url = image_url; post.attachment = ''; } } @@ -387,6 +388,7 @@ if (typeof Object.create !== 'function') { if (element.picture) { var attachment = Feed.facebook.utility.prepareAttachment(element); if (attachment) { + post.attachment_url = attachment; post.attachment = attachment; } } @@ -450,6 +452,7 @@ if (typeof Object.create !== 'function') { } } } + post.attachment_url = image; post.attachment = ''; }); } @@ -536,6 +539,7 @@ if (typeof Object.create !== 'function') { post.description = ''; post.link = element.link; if (options.show_media) { + post.attachment_url = element.images.standard_resolution.url; post.attachment = ''; } return post; @@ -590,12 +594,18 @@ if (typeof Object.create !== 'function') { post.message = Utility.stripHTML(element.text); if (options.show_media) { if (element.attachment) { - if (element.attachment.type === 'link') + if (element.attachment.type === 'link'){ + post.attachment_url = element.attachment.link.image_src; post.attachment = ''; - if (element.attachment.type === 'video') + } + if (element.attachment.type === 'video'){ + post.attachment_url = element.attachment.video.image_big; post.attachment = ''; - if (element.attachment.type === 'photo') + } + if (element.attachment.type === 'photo'){ + post.attachment_url = element.attachment.photo.src_big; post.attachment = ''; + } } } @@ -662,6 +672,7 @@ if (typeof Object.create !== 'function') { if (options.show_media) { if (element['media$thumbnail']) { + post.attachment_url = element['media$thumbnail']['url']; post.attachment = ''; } } @@ -717,6 +728,7 @@ if (typeof Object.create !== 'function') { post.social_network = 'pinterest'; post.link = element.link ? element.link : 'https://www.pinterest.com/pin/' + element.id; if (options.show_media) { + post.attachment_url = element.image['original'].url; post.attachment = ''; } return post; @@ -774,6 +786,7 @@ if (typeof Object.create !== 'function') { post.social_network = 'rss'; post.link = item.link.href; if (options.show_media && item.thumbnail !== undefined ) { + post.attachment_url = item.thumbnail.url; post.attachment = ''; } return post; From 8b8446b546cca8e0efe2eedb72487d5e5f09657a Mon Sep 17 00:00:00 2001 From: stockmind Date: Fri, 30 Mar 2018 21:35:10 +0200 Subject: [PATCH 2/2] Fix facebook image url handling --- js/jquery.socialfeed.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/js/jquery.socialfeed.js b/js/jquery.socialfeed.js index ac2eab2..666cb42 100644 --- a/js/jquery.socialfeed.js +++ b/js/jquery.socialfeed.js @@ -309,7 +309,7 @@ if (typeof Object.create !== 'function') { Utility.request(request_url, Feed.facebook.utility.getPosts); }; var fields = '?fields=id,from,name,message,created_time,story,description,link'; - fields += (options.show_media === true)?',picture,object_id':''; + fields += (options.show_media === true)?',picture,object_id':''; var request_url, limit = '&limit=' + options.facebook.limit, query_extention = '&access_token=' + options.facebook.access_token + '&callback=?'; switch (account[0]) { @@ -338,7 +338,7 @@ if (typeof Object.create !== 'function') { var result = ''; $.get(url, callback, 'json'); }, - prepareAttachment: function(element) { + prepareAttachment: function(element, geturl = false) { var image_url = element.picture; if (image_url.indexOf('_b.') !== -1) { //do nothing it is already big @@ -351,7 +351,11 @@ if (typeof Object.create !== 'function') { } else if (element.object_id) { image_url = Feed.facebook.graph + element.object_id + '/picture/?type=normal'; } - return ''; + if(geturl){ + return image_url; + }else { + return ''; + } }, getExternalImageURL: function(image_url, parameter) { image_url = decodeURIComponent(image_url).split(parameter + '=')[1]; @@ -386,9 +390,12 @@ if (typeof Object.create !== 'function') { if (options.show_media === true) { if (element.picture) { - var attachment = Feed.facebook.utility.prepareAttachment(element); + var attachment_url = Feed.facebook.utility.prepareAttachment(element, true); + if(attachment_url){ + post.attachment_url = attachment_url; + } + var attachment = Feed.facebook.utility.prepareAttachment(element, false); if (attachment) { - post.attachment_url = attachment; post.attachment = attachment; } } @@ -690,9 +697,9 @@ if (typeof Object.create !== 'function') { getData: function(account) { var request_url, - limit = 'limit=' + options.pinterest.limit, - fields = 'fields=id,created_at,link,note,creator(url,first_name,last_name,image),image', - query_extention = fields + '&access_token=' + options.pinterest.access_token + '&' + limit + '&callback=?'; + limit = 'limit=' + options.pinterest.limit, + fields = 'fields=id,created_at,link,note,creator(url,first_name,last_name,image),image', + query_extention = fields + '&access_token=' + options.pinterest.access_token + '&' + limit + '&callback=?'; switch (account[0]) { case '@': var username = account.substr(1); @@ -743,8 +750,8 @@ if (typeof Object.create !== 'function') { getData: function(url) { var limit = options.rss.limit, - yql = encodeURIComponent('select entry FROM feednormalizer where url=\'' + url + '\' AND output=\'atom_1.0\' | truncate(count=' + limit + ')' ), - request_url = Feed.rss.api + yql + '&format=json&callback=?'; + yql = encodeURIComponent('select entry FROM feednormalizer where url=\'' + url + '\' AND output=\'atom_1.0\' | truncate(count=' + limit + ')' ), + request_url = Feed.rss.api + yql + '&format=json&callback=?'; Utility.request(request_url, Feed.rss.utility.getPosts, Feed.rss.datatype); },