0

I have this code.

<ion-item ng-repeat='item in videos' class="item-thumbnail-left item-text-wrap">
        <img scr="http://placehold.it/80x80">
</ion-item>

I am trying to load an image from placehost.it but it is not loading the image. I have added

<access origin="*" />

the above code to my config.xml file. But it is still not loading when I open it on chrome. I have also enabled COR. What shall I do?

7
  • When you open it in chrome, do you see any errors in the console or network tab? Commented Aug 31, 2015 at 8:58
  • No, there are no errors. And when I inspect the element the url is corrent. Commented Aug 31, 2015 at 9:07
  • In image tag you wrote spell mistake as scr instead of src..please check it even if it will not work mean's reply me Commented Aug 31, 2015 at 10:08
  • have you changed the scr to src tag Commented Aug 31, 2015 at 11:40
  • 1
    in <img tag you spelled mistake it should src but you kept as scr as <img scr="placehold.it/80x80"> Commented Aug 31, 2015 at 12:10

2 Answers 2

1

Whitelisting the domains using cordova-plugin-whitelist solves the issue.

Add the plugin via CLI:

cordova plugin add cordova-plugin-whitelist

and then add the following line of code to your app's config.xml:

<allow-navigation href="http://*/*" />

and

this meta tag in your index.html

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

EDIT: The reason for this issue:
From Cordova 4.0.0 for Android's update:

Whitelist functionality is revamped

  • You will need to add the new cordova-plugin-whitelist plugin to continue using a whitelist

  • Setting a Content-Security-Policy (CSP) is now supported and is the recommended way to whitelist (see details in plugin readme)

  • Network requests are blocked by default without the plugin, so install this plugin even to allow all requests, and even if you are using CSP.

  • This new whitelist is enhanced to be more secure and configurable, but the Legacy whitelist behaviour is still available via a separate plugin (not recommended).

Note: while not strictly part of this release, the latest default app created by cordova-cli will include this plugin by default.

Sign up to request clarification or add additional context in comments.

Comments

1

try to use ng-src becaue you are importing from website, not locally.

Cheers

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.