just4fun
just4fun

Reputation: 537

React Native Image can't work sometimes

I created an iOS APP for university BBS (built in PHP) with React Native 0.14.

When I send request to fetch user info, I will get a record including filed avatar, which has value like http://bbs.uestc.edu.cn/uc_server/avatar.php?uid=32044&size=middle.

<Image
  style={styles.avatar}
  source={{uri: authrization.avatar}} />

It seems like a PHP method (I'm not familiar with PHP), since the value of avatar will become http://bbs.uestc.edu.cn/uc_server/data/avatar/000/03/20/44_avatar_middle.jpg if I type the original value in the browser.

However, the avatar is not displayed sometimes. See the screenshot.

Does the <Image> component only support static picture file which ends with jpg|png|gif?

Upvotes: 2

Views: 807

Answers (1)

Martin Konicek
Martin Konicek

Reputation: 40954

That URL returns a redirect. However, the Image component doesn't support redirects.

As a workaround, use a URL that returns the image. If you want support for redirects please consider sending a pull request.

Checked with curl:

$ curl -I http://bbs.uestc.edu.cn/uc_server/avatar.php?uid=32044&size=middle
HTTP/1.1 301 Moved Permanently

Upvotes: 2

Related Questions