我想获取移动设备的完整图库,以便在自定义网格中显示它们,是否可能?现在我正在使用$cordova
ImagePicker,它将我重定向到画廊,然后在选择图像后,我得到了该图像的Uri.而不是我想要完整的画廊图像uri自动选择.
调节器
$scope.getImageFromGallery = function() { // Image picker will load images according to these settings var options = { maximumImagesCount: 1,// Max number of selected images,I'm using only one for this example width: 800,height: 800,quality: 80 // Higher is better }; $cordovaImagePicker.getPictures(options).then(function(results) { // Loop through acquired images for (var i = 0; i < results.length; i++) { alert(results); $scope.image = results[i]; // Print image URI } },function(error) { console.log('Error: ' + JSON.stringify(error)); // In case of error }); }
最简单的方法是使用
cordova-gallery-api插件,请参考以下示例:
原文链接:https://www.f2er.com/angularjs/141239.htmlgalleryAPI.getAlbums(function(items) { var html = ""; for(var i = 0; i < items.length; i++) { var album = items[i]; html += '<a href="javascript:loadAlbum(\'' + album.title + '\')" class="album"><span>' + escape(album.title) + '</span></a>'; } $content.innerHTML = html; },function(error){alert(error);}); window.loadAlbum = function(albumName) { galleryAPI.getMedia(albumName,function(items) { var html = ""; for(var i = 0; i < items.length; i++) { var media = items[i]; html += '<a href="javascript:void()" class="media"><img src="file://' + media.thumbnail + '" /></a>'; } $content.innerHTML = html; },function(error){alert(error);}); };