Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not showing Twitter image if more than one image added to tweet #352

Open
bluelevel-media opened this issue Sep 9, 2019 · 1 comment
Open

Comments

@bluelevel-media
Copy link

If I get a tweet with one image in then it comes through fine, but if I get a tweet which has multiple images added then none of them come through. I don't need all of them just one would be fine. Not sure if this is a bug or whether I am doing something wrong here... any help would be great.

thanks

@bluelevel-media
Copy link
Author

bluelevel-media commented Sep 12, 2019

UPDATE:

I have found a fix for the issue. The problem was I needed to enable extended tweet mode.
This was done on line 243:

"id=" + userid + "&count=" + options.twitter.limit + "&tweet_mode=extended",

With extended tweet mode enabled I can then get more tweet information. There was still an issue with retweets and shared tweets not showing the images and also tweet text wasn't showing for all. So I have modified the code slightly to check what type of tweet it is then use the correct media url.

unifyPostData: function(element) {
                    var post = {};
                    if (element.id) {
                        console.log(element);
                        post.id = element.id_str;
                        //prevent a moment.js console warning due to Twitter's poor date format.
                        post.dt_create = moment(element.created_at, 'dd MMM DD HH:mm:ss ZZ YYYY');
                        post.author_link = 'http://twitter.com/' + element.user.screen_name;
                        post.author_picture = element.user.profile_image_url_https;
                        post.post_url = post.author_link + '/status/' + element.id_str;
                        post.author_name = element.user.name;
                        post.message = element.full_text;
                        post.description = '';
                        post.link = 'http://twitter.com/' + element.user.screen_name + '/status/' + element.id_str;
                        if (options.show_media === true) {
                            console.log("retweeted_status: " + (typeof element.retweeted_status === "undefined"));
                            if (typeof element.retweeted_status !== "undefined") {
                                if (element.retweeted_status.entities.media && element.retweeted_status.entities.media.length > 0) {
                                    var image_url = element.retweeted_status.entities.media[0].media_url_https;
                                    if (image_url) {
                                        post.attachment = '<img class="attachment" src="' + image_url + '" />';
                                    }
                                }
                            }
                            else if (typeof element.quoted_status !== "undefined") {
                                if (element.quoted_status.entities.media && element.quoted_status.entities.media.length > 0) {
                                    var image_url = element.quoted_status.entities.media[0].media_url_https;
                                    if (image_url) {
                                        post.attachment = '<img class="attachment" src="' + image_url + '" />';
                                    }
                                }
                            }
                            else {
                                if (element.entities.media && element.entities.media.length > 0) {
                                    var image_url = element.entities.media[0].media_url_https;
                                    if (image_url) {
                                        post.attachment = '<img class="attachment" src="' + image_url + '" />';
                                    }
                                }
                        }
                        }
                    }
                    return post;
                }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant