[Problem] Saving imageUri inside Array then displaying Images using 'ng-repeat'

Hello, I’m John and I am trying to create a self increasing slide box where I can add Images from the Gallery to it.

Let’s start with the slide item using ‘ng-repeat’ property :

<ion-slide ng-repeat="image in images">
       <img class="add-collection-item-div-image-container" src="{{image.imageUrl}}" id="myImage" >
</ion-slide>

Now there is the ‘cameraSuccess’ function wich is called when I select an image from the pic gallery or from the device camera:

function cameraSuccess(imageURI) {
            
            if (imageURI.substring(0, 21) == "content://com.android") {
                var photo_split = imageURI.split("%3A");
                imageURI = "content://media/external/images/media/" + photo_split[1];
            }
            $scope.images[$scope.images.length] = { imageUrl: imageURI};
            $ionicSlideBoxDelegate.update();
        }

The problem is : The picture taken from the Camera and the picture that comes from the gallery is never displayed on the ion-slide item.

These are the imageUri I get from the device camera and the pic gallery:

Pic gallery imageUri : "content://media/external/images/media/5240"
Device camera imageUri : "file:///storage/emulated/0/Android/data/com.ionicframework.app802132/cache/478.jpg"

Please does any one have a solution for that?

Thanks!

[EDIT]

Removed this code

.config(function ($stateProvider, $urlRouterProvider, $compileProvider) {
$compileProvider.imgSrcSanitizationWhitelist(‘img/’);
})

from ‘app.js’ and the Image from the device Camera works now but the image from the Pic Gallery still does not display…

1 Like

Try adding below lines in your app.js

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

Thank you so much h4ck3rviv3k!

It worked beatifully! :smile:

Hey guys,

Any chance you can take a look at my similar question?

I think it is a problem with the image URI, but I am not sure :confused: Taking a series of photos in one view, display them all in the next

did u fix this mr FlomerBoy?