Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 6722d08

Browse files
authored
Merge pull request #14 from billmalarky/issue-13-local-file-not-used
Issue 13 local file not used
2 parents 5d5d461 + 84b3b07 commit 6722d08

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/imageCacheHoc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
// Load dependencies.
1717
import React from 'react';
18-
import { ViewPropTypes } from 'react-native';
18+
import { Platform, ViewPropTypes } from 'react-native';
1919
import PropTypes from 'prop-types';
2020
import FileSystemFactory, { FileSystem } from '../lib/FileSystem';
2121
import traverse from 'traverse';
@@ -183,10 +183,13 @@ export default function imageCacheHoc(Image, options = {}) {
183183
// If media loaded, render full image component, else render placeholder.
184184
if (this.state.localFilePath) {
185185

186+
// Build platform specific file resource uri.
187+
const localFileUri = (Platform.OS == 'ios') ? this.state.localFilePath : 'file://' + this.state.localFilePath; // Android requires the traditional 3 prefixed slashes file:/// in a localhost absolute file uri.
188+
186189
// Extract props proprietary to this HOC before passing props through.
187190
let { permanent, ...filteredProps } = this.props; // eslint-disable-line no-unused-vars
188191

189-
let props = Object.assign({}, filteredProps, { uri: this.state.localFilePath });
192+
let props = Object.assign({}, filteredProps, { source: { uri: localFileUri } });
190193
return (<Image {...props} />);
191194
} else {
192195

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-image-cache-hoc",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"description": "React Native Higher Order Component that adds advanced caching functionality to the react native Image component.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)