ImageView does not show image from twitpic url due to 302 redirect

You must Login before you can answer or comment on any questions.

Hi,

I like to show image thumbs in my app from twitpic urls, for which I use the ImageView. These urls have the following format: http://twitpic.com/show/thumb/430eqg

In my web browser I clearly get an image back, while it fails on the client. I use other image providers as well, and their image redirects work. They have a 301 (Moved Permanently) response header, while twitpic has a 302 (Moved Temporarily) header.

Any suggestions on what I could do?

Thanks.

2 Answers

That's because twitpic redirects you to the full URL , you are using shortcuts.

The problem is that, the request doesn't follow the redirect , so if location from twitpic is returned , your application can't follow it.

Find a way to find the full URL which is returned from Twitpic. You could use a server-side proxy, too. So lets say , PHP , can do a file_get_contents() to the shortcut URL , and return that to the app without redirect.

https://appcelerator.lighthouseapp.com/projects/32238/tickets/2513-webview-does-not-follow-redirects-on-ios

Twitpics work fine for me in webViews.

If you have a twitPic url eg: http://twitpic.com/2we1ko

Then the image is located at http://twitpic.com/show/large/2we1ko.jpg (yes, it's a redirect)

To display the image in a webView I use:

var twitpic_url = 'http://twitpic.com/2we1ko';
 
var twitpic_img = twitpic_url.replace("twitpic.com\/","twitpic.com\/show\/large\/")+'.jpg';
var twitpicHtml = '<html><body><img width="300" src="'+twitpic_img+'"></body></html>';
var twitpic_webview = Titanium.UI.createWebView({
    html: twitpicHtml,
    height:'auto',
    left:0,
    right:0,
    top:0
});
 
win.add(twitpic_webview);
hope this helps!

Your Answer

Think you can help? Login to answer this question!