ascoders / react-native-image-viewer

🚀 tiny & fast lib for react native image viewer pan and zoom
MIT License
2.44k stars 577 forks source link

How can load images from phone local. #437

Open zuijiusi opened 3 years ago

zuijiusi commented 3 years ago

const imgFunctionArray3 = [ {url: '',props:{source:require('../images/photo_placeholder.png')}}, {url: '',props: { source: { uri: 'content://media/external/images/media/45204'} } }, {url:'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1537850155794&di=4efaecca3f367346ff49c42f8f89d9f2&imgtype=0&src=http%3A%2F%2Fimg3.duitang.com%2Fuploads%2Fitem%2F201206%2F26%2F20120626190359_MjB3s.thumb.700_0.jpeg'} ]

zuijiusi commented 3 years ago

imgFunctionArray = [ {url: '',props: { source: { uri:'file:/storage/emulated/0/Pictures/Screenshots/Screenshot_20201112-162211.png'} } }, ]; the path from my phone local album,but can‘t show in ImageViewer。What should I do

jaaywags commented 3 years ago

I had the same issue. I ended up hosting the image remotely and accessing it that way. Might not be the solution you are looking for but it is a solution.

sakul-budhathoki commented 3 years ago

Hi @zuijiusi , @jaaywags . I also got issue using local images. I managed to solve it by following code: -

import {Image} from 'react-native';
import LocalImage from './local.png';

<ImageViewer imageUrls={[{ url: Image.resolveAssetSource(LocalImage).uri }]} />