2

Using <img> with the src, a local file works fine on a PC. But on Android 7 it doesn't get displayed; instead a no photo icon is displayed. How can I solve this?

<img src="photo.png">

(The photo.png is placed in the same folder as the .html file.)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

2 Answers2

0

You have to declare the path of the photo:

<img sc = " xxxpathxxx/"photo.png">

Else, make a separate image folder and call it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

The issue with this is how Webview works with local files. File paths aren't the same as your PC Google Chrome paths where you can drag an HTML file to the browser and have it be loaded in a certain path, and because of that photo.png doesn't direct anywhere.

Instead, you need to use the file:// schema to access local files. Regardless of whether photo.png is local or an Internet resource, you'll need to use photo.png's absolute path, e.g.:

http://localhost/path/to/photo.png
http://www.mywebsite.com/path/to/photo.png
file://data/local/tmp/photo.png
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
A. Abramov
  • 1,823
  • 17
  • 45