ionic 3 photo library image not displayed on img tag

混江龙づ霸主 提交于 2019-12-05 15:04:27

I think I've found a solution here - change WKWebView to UIWebView. Then the pictures show up.

I found the reason in this post. Also ionic official doc also proves that currently WKWebView doesn't support local files.

I hope my post will help someone with similar situation, and do hope ionic team could soon improve WKWebView in terms of custom schema file path. Happy coding~!

This works like a charm:-

If you are using wkwebview(which is now default for new apps) then follow below steps,

import { normalizeURL} from ‘ionic-angular’;

store your image path in some new variable.
var imagePath = this.file.dataDirectory + “test.png”;
this.tempImagePath = normalizeURL(imagePath);

then in your html file,
use tempImagePath as image src.

Source: https://forum.ionicframework.com/t/downloaded-image-is-not-displayed-ionic-3-8/110912/2

To see if WKWebview is installed correctly, try adding this to your main app component:

if (window.indexedDB) {
  console.log('I have WKWebview installed!');
} else {
  console.log('I have UIWebView installed!');
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!