I have a problem for load url with no http://
Exemple:
< img src=“http://www.image.com”/> WORK.
< img src="//www.image.com"/> NOT WORK. Because the phone search with :file//www.image.com
This problem is only present in device. No problem with ionic serve in browser.
My config.xml :
< access origin=""/>
< allow-navigation href="" />
I can’t use ng-src because is a html code get from API.
The plugin whitelist is already in my project:
package.json:
“cordovaPlugins”: [
“cordova-plugin-device”,
“cordova-plugin-console”, “cordova-plugin-whitelist”,
“cordova-plugin-splashscreen”,
“cordova-plugin-statusbar”,
“ionic-plugin-keyboard”,
“cordova-plugin-x-toast”
]
Work in browser.
But in Android device not work. Because i see console with chrome inspect (chrome://inspect/#devices) :
“Request URL:file://www.mysite.fr/Hazard.jpg”
Yes ! But is not a solution for my problem !!!
I can’t change my code… because my html code is recovered by an API (Wordpress). It’s a image in content of article.
Hi,
If you cannot change the link source format, try to concatenate it with "http:"
I mean using ng-src="http:{{image_url}}" so the link would be correct.
ok so try to change “//www.image.com” to “http://www.image.com” before the to put it in ng-bind-html
by using the replace function: var newHTml = article.content.rendered.replace('//www.image.com' , 'http://www.image.com');
hope that would work for you
sincerely, I don’t know how you can find a solution (and I’ll be really glad to know it if there is one).
because If there is no protocol, the link is by default considered a file path on the phone (wich would not work because the folder ‘//’ don’t exist).