pavelk2 / social-feed

JavaScript plugin that shows a user feed from the most popular social networks
http://pavelk2.github.io/social-feed-example/
MIT License
962 stars 304 forks source link

Twitter don't show images in the feed #255

Open mutiullah7 opened 7 years ago

mutiullah7 commented 7 years ago

Twitter feed doesn't show images which are added into the tweets, like @audi have images in the tweet attached, but feed don't show images.

martijngastkemper commented 7 years ago

Maybe my pull request (#240) solves the problem. Can you test that branch? If it works I'll merge the pull request.

mutiullah7 commented 7 years ago

It show images, but now all, some images are missing from the tweets, also i noticed, it also show those tweets which i've relied to, (the replied tweets), if i only want to show the tweets i've tweeted not replied tweets, any option for that? like i just only want to show my tweets not the replies i've made to others. i hope you got my point, what im trying to say.

martijngastkemper commented 7 years ago

Did the replies appear after you applied #240 or did you already have that problem. If the last is the case you need to open a new issue, because that's off topic

mutiullah7 commented 7 years ago

No I already have that problem, but back to the topic, i've added the tweet_mode also changed the script you changed in #240 but no success not all the images shows up, some images are still missing.

martijngastkemper commented 7 years ago

Did you set set tweet_mode to extended?

mutiullah7 commented 7 years ago

both, compatibility and extended

taylankasap commented 7 years ago

I had the same problem. Some tweets show images some don't even though they have images. I did some research and found out enabling extended mode is half the solution. After that you need to use extended_entities under retweeted_status in API response to access media of extended retweets. I'm not sure about extended non-retweets.

mutiullah7 commented 7 years ago

Hi @taylankasap how can i use extended_entities please help me with it

taylankasap commented 7 years ago

@mutiullah7 you'll need to manually change the jquery.socialfeed.js file. Find the Feed.twitter.utility.unifyPostData function body. There is an ìf block (options.show_media === true) there. Since I only needed to use extended mode I'm not sure if this still works with compatibility mode so if you need to use both modes you may need to modify it. Here is the code I used inside that if block:

var elementEntities = {};
if (element.entities.media && element.entities.media.length > 0) {
    elementEntities = element.entities;
} else if (element.retweeted_status && element.retweeted_status.extended_entities && element.retweeted_status.extended_entities.media && element.retweeted_status.extended_entities.media.length > 0) {
    elementEntities = element.retweeted_status.extended_entities;
}

if (elementEntities.media && elementEntities.media.length > 0) {
    var image_url = elementEntities.media[0].media_url;
    if (image_url) {
        post.attachment = '<img class="attachment" src="' + image_url + '" />';
    }
}
mutiullah7 commented 7 years ago

Doesn't help, no images still after adding the code as you suggested.

asalem1990 commented 6 years ago

@martijngastkemper Thanks dude, your solution has solved it, just got your updated jquery.socialfeed.js file as is replaced the old one with it, then I used tweet_mode: 'extended' in the calling function and it worked as expected :)