themyth92 / ngx-lightbox

Lightbox2 use with angular >= 5
MIT License
115 stars 70 forks source link

data:image/png;... not working #73

Open AbhinavAtul opened 4 years ago

AbhinavAtul commented 4 years ago
  1. included the lightbox.css
  2. no error on console,
  3. tried passing both dataUri = data:image,.... and safeUrl = this.domSanitizer.bypassSecurityTrustUrl(dataUri), no error on console either
this.lightBox.open(
                [{
                    src: dataUri, //also tried this.domSanitizer.bypassSecurityTrustUrl(dataUri)
                    caption: '',  
                    thumb: '', //also tried dataUri or the safeurl directly
                }],
 0
 )
BerndtHamboeck commented 3 years ago

Just a quick hack, if you want to get it up and running:

LightboxComponent.prototype._validateInputData = function () {
    // if (this.album &&
    //     this.album instanceof Array &&
    //     this.album.length > 0) {
    //     for (var i = 0; i < this.album.length; i++) {
    //         // check whether each _nside
    //         // album has src data or not
    //         if (this.album[i].src) {
    //             continue;
    //         }
    //         throw new Error('One of the album data does not have source data');
    //     }
    // }
    // else {
    //     throw new Error('No album data or album data is not correct in type');
    // }
    // // to prevent data understand as string
    // // convert it to number
    // if (isNaN(this.currentImageIndex)) {
    //     throw new Error('Current image index is not a number');
    // }
    // else {
    //     this.currentImageIndex = Number(this.currentImageIndex);
    // }
    return true;
};
LightboxComponent.prototype._registerImageLoadingEvent = function () {
    var _this = this;
    var preloader = new Image();
    preloader.onload = function () {
        _this._onLoadImageSuccess();
    };
    var src = this.album[0].src;
    preloader.src = src; //this._sanitizer.sanitize(core_1.SecurityContext.URL, src);
};