My phone redirect url //www. with :file//

Hello,

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 search a solution, but not found.

Help me please !
Sorry for my bad english.

you want to load images via http? use ng-src and add plugin whitelist plus meta tag in your index html file…

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”
]

I have add a meta tag in index.html:

But not work…

i think you can use it also… try it first then comeback again… let’s see what are the errors in your log…

Ok.

I have tested:
< img ng-src="//www.mysite.fr/Hazard.jpg" />

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”

=/

change the url to http://www.mysite.fr/Hazard.jpg

it works on android device… 8@ =/

does it work correctly??

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.

so you just need to use {{image_url}} for that to load images with api…

No it not possible… !

oh i see, let’s just wait for the one who can help you with that…

1 Like

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.

No ! Because i havn’t {{image_url}}.
I have:

< div id=“content_html” ng-bind-html=“trustAsHtml(article.content.rendered)”>

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 :slight_smile:

Yes, i had the idea. But i don’t think it’s good .
Because the problem is not really solved properly.

Also i use a fb sdk for get video with page.
And in the code generate by FB.XFBML.parse() there is also a links with :// for show videos. :disappointed_relieved:

I need a real solution.

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).

Still, I thought I’d seen it work a few days ago on my phone.
I dreamed ? (I do not think so).

I came back in the comits but without success.
I created a new project, but also without success.

:rage:

OK ! I wasn’t dreaming !
It works with ionic run android --devices --livereload ! :rage::rage:
But whitout --livereload not work ! :cry:

Let’s go for fun to replace characters ! :cry::cry::cry::scream::rage:

1 Like