Hi There

First off, thanks for this module, really useful. In the use case I needed this for, the client wanted images to come through in the twitter feed, this did not seem to work out the box?

I have edited the module, but would like to submit a patch to allow others to have images too, see below for what I have done.

Stack overflow on how to get images from twitter: https://stackoverflow.com/questions/39688477/twitter-images-with-large-n...

Edits to TwitterController.php

//"
 if ($bearer_token) {
            // build the HTTP GET query
            $body = array(
                'headers' => array(
                    "Authorization" => "Bearer " . $bearer_token,
                ),
                'query' => array(
                    "count" => $this->config->get('twitter_item_to_fetch'),
                    "screen_name" => $this->config->get('twitter_social_feed_screen_name'),
                    'tweet_mode' => 'extended', //Add in here to get extended mode
                ),
                'proxy' => $this->config->get('proxy'),
                'verify' => FALSE,
            );
//"

//"
$twitter_value['text'] - changed to $twitter_value['full_text']
//"

//"
                    //added in new section to pull images
                   if(array_key_exists('media', $twitter_value['entities'])) { 
                    $twitter_tweets[$key]['image'] = "<img src=" . $twitter_value['entities']['media'][0]['media_url_https'] . ">";
                    } else {
                        $twitter_tweets[$key]['image'] = "<img src=''>";
                    }
//"

//"
                    if ($twitter_hash_tag == 1) {
                        $twitter_tweets[$key]['tweet'] = preg_replace_callback(
                                '/#(\\w+)|@(\\w+)/', function ($hash) {
                            if ($hash[0][0] == '#') {
                                $url = URL::fromUri('//twitter.com/hashtag/' . $hash[1], array('attributes' => array('target' => '_blank')));
                                return \Drupal::l($hash[0], $url);
                            }
                            if ($hash[0][0] == '@') {
                                $url = URL::fromUri('//twitter.com/' . $hash[2], array('attributes' => array('target' => '_blank')));
                                return \Drupal::l($hash[0], $url);
                            }
                        }, $twitter_tweets[$key]['tweet'] . $twitter_tweets[$key]['image'] //Added in here to get images to show in tweet.
                        );
                    }
//"

Thanks so much, let me know if the above makes sense.

Comments

TheWagener created an issue. See original summary.

TheWagener’s picture

Issue summary: View changes
apaderno’s picture

Issue tags: -twitter images, -'tweet_mode' => 'extended'

I am removing issue tags used from one to four issues. I apologize for bumping the issue.

govind.maloo’s picture

@TheWagener A patch would be better to fix the above.