rolinger
rolinger

Reputation: 3060

Ionic v1 src=unsafe for all images with latest [email protected]

Just built a new Mac cordova/ionic envorinoment with all the latest and greatest versions of Cordova, Node, etc - but still running an Ionic v1 project. My app is compiling and deploying to devices but all my images are broken and the source code shows like:

<img class="loading" ng-src="img/ajax_loading.gif"src="unsafe:ionic://myApp/img/ajax_loading.gif">

Old Mac: [email protected] ([email protected]) with [email protected] New Mac: [email protected] ([email protected]) with [email protected]

Looks like something changed between 5.0.1 and 5.1.1 - but I don't know what. Is there a plugin to remedy this or how do I go about fixing this. I have lots of images in my app that are all broken.

Upvotes: 0

Views: 799

Answers (1)

JSON
JSON

Reputation: 59

I had the same issue, and resolved it by following this answer: cordova ios WKWebView upgrade - errors when showing some images

Basically it stems from WkWebView being less permissive than the UIWebView from whence you came.

I had to add the following config block to my app.js:

.config(['$compileProvider', function ($compileProvider) {
  $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|blob|ionic):|data:image/);
}

If you discover as I did, that some internal hrefs no longer work, add this line to the config block as well:

$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|local|data|ionic|tel|mailto):/);

Upvotes: 6

Related Questions