lunes, 20 de octubre de 2014

IONIC Problemas al mostrar una imagen local (sacada con la camara) en un control IMG

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...
Try adding below lines in your app.js
.config(['$compileProvider', function($compileProvider) {
         $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|blob|content):|data:image\//);
        }])
1 person liked this.
Thank you so much h4ck3rviv3k!
It worked beatifully! smile

Fuente: http://forum.ionicframework.com/t/problem-saving-imageuri-inside-array-then-displaying-images-using-ng-repeat/9049

No hay comentarios:

Publicar un comentario

Jesús Moreno - Ingeniero Ténico Informático - consultor Informático

Hola, soy Jesús Moreno Ingeniero Técnico Informático en sistemas por la US y propietario de éste blog. Mi trabajo en los ultimos años se ...