Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display an image stored on phone

Tags:

react-native

I have succesfully been able to take a photo inside my app and store it on the phone, but how do I display it?

I tried this static approach but it does not work (Yes the image is there :) )

 <Image width={40} height={40} source={{uri: '/storage/emulated/0/DCIM/IMG_20161201_125218.jpg'}} />
like image 413
D3athSpank Avatar asked Dec 01 '16 12:12

D3athSpank


2 Answers

Even I faced this issues and got it resolved. You have to prepend the the file path with file:// (mind the double /).

<Image source={{uri:'file:///storage/emulated/0/DCIM/IMG_20161201_125218.jpg'}}
    style={myImageStyle}/>

Here's a reference!

I hope this helps :)

like image 63
DesignThought Avatar answered Sep 29 '22 13:09

DesignThought


    <Image source = {{uri: "file:///storage/emulated/0/appiwell/image/qkpOyUaRla.jpg", 
                    width: responsiveWidth(100), 
                    height: responsiveHeight(100)}}/>

Notice, should set width, height inside {uri, width, height}. Width, height in style maybe didn't work.

responsiveWidth, responsiveHeight here https://www.npmjs.com/package/react-native-responsive-dimensions

like image 37
Tuan Nguyen Avatar answered Sep 29 '22 13:09

Tuan Nguyen