ginader / easychirp

easychirp.com - Web accessibility for the Twitter website application
11 stars 1 forks source link

if tweet contains image link, add image thumbnail #73

Closed weboverhauls closed 10 years ago

weboverhauls commented 11 years ago

when a tweet contains a link to an image, show a thumbnail of the image inline in the tweet

weboverhauls commented 11 years ago

For reference from original EC code:

    //TwitPic or yFrog
    $regexp = "/http\:\/\/(?:www\.)?(twitpic.com|yfrog.com|mypict.me)\/(\w+)/i";
    if (preg_match($regexp, $s)) {

        preg_match($regexp, $s, $matches);
        //print_r($matches); die;

        echo '<div style="width:90px; float:right; padding-left:20px;"><a class="noHover" href="'.$matches[0].'" rel="external">';
        echo '<img src="http://';
        if ($matches[1]=="twitpic.com") {
            echo 'twitpic.com/show/thumb/'.$matches[2].'" alt="small image from '.$matches[1].'" height="75" width="75" /></a></div>';
        }
        else if ($matches[1]=="yfrog.com") {
            echo 'yfrog.com/'.$matches[2].'.th.jpg" alt="small image from '.$matches[1].'" height="75" width="75" /></a></div>';
        }
        else if ($matches[1]=="mypict.me") {
            echo 'mypict.me/getthumb.php?id='.$matches[2].'" alt="small image from '.$matches[1].'" /></a></div>';
        }
    }
weboverhauls commented 10 years ago

Image thumbnail now displays in tweets (when Twitter API provides URL of image). Didn't use same method as above. Need to add functionality for Imgur and Twitpic.