Im trying to show a local image from gallery, and image recenty taken , but isnt showing.
If i set a color, web image is showing, but not locally
Here is my code
// foto do album
photoLibrary: function(image) {
document.addEventListener('deviceready', function() {
navigator.camera.getPicture(success, function(message) {
switch (_TELA_ATUAL) {
case _TELAS_CRIAR_CARTAO.sideA[0]:
$('#formA [data-action="galleryLadoA"]').attr('data-display', 'none')
$('button[data-action="photoLadoB"]').prop('disabled', false).css('opacity', 1)
$('button[data-action="galleryLadoB"]').prop('disabled', false).css('opacity', 1)
app.esconderElementos(9)
break
case _TELAS_CRIAR_CARTAO.sideB[0]:
$('#formB [data-action="galleryLadoB"]').attr('data-display', 'none')
app.esconderElementos(10)
$('#backB').addClass('on')
break
}
}, {
quality: 100,
allowEdit: true,
targetWidth: 400,
targetHeight: 300,
correctOrientation: true,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
})
function success(imageURI) {
console.log('Success ')
if (image.parent().parent().hasClass('face') && image.parent().parent().hasClass('ladoA')) {
_TELA_ATUAL = _TELAS_CRIAR_CARTAO.sideA[1]
$('#formA, #backA').addClass('on')
$('.faceIPad #formA').addClass('on')
$('.faceIPad.ladoA .selecionarItemIPad').hide()
$('#formA .image').css('display', 'block')
$('#formA [data-action="galleryLadoA"]').attr('data-display', 'block')
$('button[data-action="photoLadoB"]').attr('disabled', 'disabled').css('opacity', 0.3)
$('button[data-action="galleryLadoB"]').attr('disabled', 'disabled').css('opacity', 0.3)
} else {
_TELA_ATUAL = _TELAS_CRIAR_CARTAO.sideB[1]
$('#formB, #backB').addClass('on')
$('.faceIPad.ladoB .selecionarItemIPad').hide()
$('#formB [data-action="galleryLadoB"]').attr('data-display', 'block')
$('#backB').addClass('on')
$('#formB .image').css('display', 'block')
}
window.resolveLocalFileSystemURL(imageURI, function(fileEntry) {
console.log('file ' + imageURI)
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(system) {
system.root.getDirectory('files', {
create: true,
exclusive: false
}, function(file) {
console.log('file ' + file)
fileEntry.copyTo(file, CryptoJS.MD5(Date()).toString() + '.jpg', function(entry) {
console.log('>>>>>>>>>>entry.nativeURL ' + entry.nativeURL)
//image.src = "data:image/jpeg;base64," + entry.nativeURL;
//
image.css(
'background', 'url("file://localhost/persistent/DCIM/Camera/IMG_20160823_141541.jpg") 0 center no-repeat'
)
image.parent().find('input[name="elemento"]').val(entry.nativeURL)
image.css({
'background-size': 'cover'
})
}, fail)
}, fail)
}, fail)
}, fail)
function fail(error) {
console.log(error.code)
}
}
}, false)
}