簡體   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