繁体   English   中英

使用base64进行照片擦除,图片

[英]Photoswipe with base64, Images

我正在使用Phonegap(Cordova-1.9.0)和jQuery Mobile 1.0.1开发iPad应用程序。 我需要为我的应用程序使用图片库。在我的应用程序中,我找到了photowipe图片库。 我从iPad相机捕获图像并将其另存为Camera.DestinationType.DATA_URL(Phonegap api)。 我的图像保存为base64,键入。

将图像另存为Camera.DestinationType.FILE_URI时,Photoswipe图像库工作正常。

但是我的问题是如何使用Camera.DestinationType.DATA_URL使用photowipe画廊?

谢谢

我找到了类似问题的解决方案。

我在网页中将photoSwipe与base64结合使用,并且它的工作方式如下:

<li><a href="data:image/png;base64,<c:out value='${entry.imagenString}'/>"><img src="data:image/png;base64,<c:out value='${entry.imagenString}'/>"></a></li>

在href和src属性中,我将base64字符串加上表示法以指示它是base64。

我将尝试在Phonegap中使用它,但是我认为它必须是相同的代码。

编辑:我在Phonegap中测试了它,并且可以正常工作。

我用这个:

var imagesArray = data.callback.include.images;
    // images : 
    if(imagesArray && imagesArray.length > 0  && imagesArray != null && imagesArray != undefined){
        var images = imagesArray.map((item)=>{
            var link = item.trim();
            var base = link.split('base64,');
            var a = base[0];
            var b = base[1];
            return `<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
                <a href=${a}base64,${b} itemprop="contentUrl" data-size="1024x1024">
                    <img src=${a}base64,${b} itemprop="thumbnail" alt="Image description" />
                </a>
                <figcaption itemprop="caption description">CAPTION :</figcaption>                   
            </figure>`
        })
        // building the gallery : 
        var now = new Date().getTime();
        var galleryClassName = "gal-" + shareId + "-" + commentId + "-" + now;
        var gallery = `<div class="comments-gallery ${galleryClassName} gallery" itemscope itemtype="http://schema.org/ImageGallery">
                         ${images}      
                    </div>`;
    }else { gallery = "" }

然后包含gallery变量,然后通过调用其类将其初始化为

var output = `<div class="row"> ${gallery} </div>`;
 // init gallerires : 
        initPhotoSwipeFromDOM("." + galleryClassName);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM