Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use local tmp file path for Image.source #751

Closed
mattotodd opened this issue Apr 8, 2015 · 10 comments
Closed

Unable to use local tmp file path for Image.source #751

mattotodd opened this issue Apr 8, 2015 · 10 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@mattotodd
Copy link

I am trying to use a local tmp file for the source of an Image and keep seeing error "Unrecognized tag protocol"

from the docs:

source {uri: string}
uri is a string representing the resource identifier for the image, which could be an http address, a local >file path, or the name of a static image resource (which should be wrapped in the >required('image!name') function).

Have tried (giving the image explicit height and width)

<Image style={styles.thumb} source={{uri:"/var/mobile/Containers/Data/Application/5938C9F8-0A9D-40DD-AB9F-CD2C772439E7/tmp/thumbimage_8gVFD"}} />

<Image style={styles.thumb} source={{uri:"file:///var/mobile/Containers/Data/Application/5938C9F8-0A9D-40DD-AB9F-CD2C772439E7/tmp/thumbimage_8gVFD"}} />

<Image style={styles.thumb} source={require("image!"+"/var/mobile/Containers/Data/Application/5938C9F8-0A9D-40DD-AB9F-CD2C772439E7/tmp/thumbimage_8gVFD"} />

Loading web assets or static image resource works just fine.

@mattotodd
Copy link
Author

Found the answer, need to pass isStatic to the source of the image.

I feel this should be added to the Image docs

<Image style={styles.thumb} source={{isStatic:true, uri:"/var/mobile/Containers/Data/Application/5938C9F8-0A9D-40DD-AB9F-CD2C772439E7/tmp/thumbimage_8gVFD"}} />

@vjeux
Copy link
Contributor

vjeux commented Apr 8, 2015

Would be nice indeed. Want to send a pull request?

@mattotodd
Copy link
Author

np

@menway
Copy link

menway commented Apr 22, 2015

How to avoid using absolute path for local file uri?

@idibidiart
Copy link

isStatic didn't work for me... resorted to adding images into images.xcassets as described in the docs ... too bad it's not called images.xcasettes

@PimDeWitte
Copy link

For anyone coming here looking to solve the android file loading issue, you need to put file:// in front of your file on android

@vishalkakadiya
Copy link
Contributor

vishalkakadiya commented Oct 25, 2016

@idibidiart I know it's very late to comment over here, but this can help others in Future.

In my case tag must have

width and height in style property

isStatic : true in source property

to display image, otherwise it wan't visible.

@1c7
Copy link

1c7 commented Jan 21, 2018

2018 now, using React Native 0.52
isStatic:true totally work!
Thanks!

@jayasimhaprasad
Copy link

@vishalkakadiya thank you very much for this tip , the image started showing up as soon as i specified the height and the width property

@caiosba
Copy link

caiosba commented Apr 14, 2018

What worked for me on Android was a combination of many comments here:

  • isStatus: true
  • Prepend the file path with file://
  • Set the dimensions

@facebook facebook locked as resolved and limited conversation to collaborators May 29, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

10 participants