nidaros
nidaros

Reputation: 85

safari img src with redirect

I have a fiddle with two images. Both images loads fine in Chrome, but only the first image loads in iPhone5 Safari. The only difference I can see is that the second src (the twitter one) has a redirect. How can I make this work also for iPhone/Safari?

<img src="http://3.bp.blogspot.com/-fOcTU5i5JdY/UovGWW8fgOI/AAAAAAAAB68/0dQJNRbknZg/s1600/628954_1280x1024-1.jpg" height="50" width="50">
<img src="http://twitter.com/twitter/profile_image?size=bigger" height="50" width="50">

https://jsfiddle.net/gsz2Ltjq/

I know that I can authenticate with twitter to fetch the profile picture from a direct link, but I would rather get the above link to work.

Upvotes: 0

Views: 1251

Answers (1)

Alamri
Alamri

Reputation: 2182

here I figured how to show redirected image scr on iOS safari

$image = 'https://twitter.com/twitter/profile_image?size=bigger';
$imageData = base64_encode(file_get_contents($image));
$src = 'data: image/png;base64,'.$imageData;
$image = '<img src="'.$src.'"/>';

It works with Twitter as they use image/png mime type

Upvotes: 0

Related Questions