New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webp custom content loads JPG on remove() #2037
Labels
Comments
Another dirty fix without modifying source files: photoswipe.on("destroy", function () {
this.mainScroll.itemHolders.forEach((itemHolder) => {
const content = itemHolder.slide?.content
if (content?.pictureElement) content.element = content.pictureElement
})
}) Not sure if this have any side effects |
Saving the pictureElement in the contentElement as mentioned by @michaelkhabarov doesn't solves the problem in our project. The destroy/remove action still loads the jpeg version. Is there any known solution? UPDATE lightbox.on('destroy', (e) => {
lightbox.pswp.mainScroll.itemHolders.forEach((itemHolder) => {
const content = itemHolder.slide?.content;
if (content?.pictureElement) {
content.element = content.pictureElement;
}
});
});
lightbox.on('contentRemove', (that) => {
const pictureElement = that.content?.pictureElement;
if (pictureElement) {
that.content.element = pictureElement;
}
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using webp picture solution as presented here : https://photoswipe.com/custom-content/#using-webp-image-format
You can observe closing photoswipe triggers the loading of jpg image, eg : open the first mountain image, then watch network in dev tools while closing photoswipe, you will see that the jpg version of the image is requested on closing
I managed to resolve the problem my modifying remove() functions in both photoswipe-lightbox.esm.js and photoswipe.esm.js adding this :
if (this.element && this.element.parentNode && !this.pictureElement) { this.element.remove(); } if (this.pictureElement && this.pictureElement.parentNode) { this.pictureElement.remove(); }
in both functions
But this is not the cleanest way to do it I suppose, I know the "real" picture feature is being developed, but until then if some people want to use my dirty fix here it is
The text was updated successfully, but these errors were encountered: