Open GHNature opened 1 year ago
I am sorry, but I do not understand exactly what the issue is about. There is no "download" to click in PhotoSwipe 5, so this would first have to be added. Do you want to have a "download" option for PhotoSwipe 5 as well?
Furthermore - what means "will open a new tab, can it start downloading directly after clicking the button". What should be in the new tab and what button are you talking about?
And finally - what has "cross-domain" to do with that all? The download option in PhotoSwipe 4 works regardless from which domain the image is being used from - however it will just link directly to the image. What the browser will do with the image can not be changed by PhotoSwipe, that only depends on what the server will send to the browser.
I am sorry, but I do not understand exactly what the issue is about. There is no "download" to click in PhotoSwipe 5, so this would first have to be added. Do you want to have a "download" option for PhotoSwipe 5 as well?
Furthermore - what means "will open a new tab, can it start downloading directly after clicking the button". What should be in the new tab and what button are you talking about?
And finally - what has "cross-domain" to do with that all? The download option in PhotoSwipe 4 works regardless from which domain the image is being used from - however it will just link directly to the image. What the browser will do with the image can not be changed by PhotoSwipe, that only depends on what the server will send to the browser.
Since I wanted it to show a download button, I switched to Phtoswipe 4, and when I clicked the download button, the browser didn't download the image directly, but reopened a tab to display the image. I searched and found out that it is because the download attribute of the A tag is only applicable to the case of the same origin of the domain name. I opened your Demo Site in Chrome and it also opened a new tab to display the image.
Since I wanted it to show a download button, I switched to Phtoswipe 4, and when I clicked the download button, the browser didn't download the image directly, but reopened a tab to display the image. I searched and found out that it is because the download attribute of the A tag is only applicable to the case of the same origin of the domain name. I opened your Demo Site in Chrome and it also opened a new tab to display the image.
Yes, that is the expected behaviour. A browser will only offer something to download if the server sends a HTTP-Header in the response with Content-Disposition: attachment
or Content-Disposition: attachment; filename=...
.
Also see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition.
The attribute download
in a link also indicates, that the linked resource should be offered for downloading, but there it is not defined how the browser actually handles that. Browsers also may just open the image even if the link contains download
. Also see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
The only solution to this would be to implement a proxy service which fetches the image on its own and sends the result with the required HTTP headers to force the browser to download it instead of opening it directly.
I will see what I can do - but this will only be done when I also add a download option for PhotoSwipe 5, so don't expect anything soon.
Since I wanted it to show a download button, I switched to Phtoswipe 4, and when I clicked the download button, the browser didn't download the image directly, but reopened a tab to display the image. I searched and found out that it is because the download attribute of the A tag is only applicable to the case of the same origin of the domain name. I opened your Demo Site in Chrome and it also opened a new tab to display the image.
Yes, that is the expected behaviour. A browser will only offer something to download if the server sends a HTTP-Header in the response with
Content-Disposition: attachment
orContent-Disposition: attachment; filename=...
.Also see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition.
The attribute
download
in a link also indicates, that the linked resource should be offered for downloading, but there it is not defined how the browser actually handles that. Browsers also may just open the image even if the link containsdownload
. Also see: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aThe only solution to this would be to implement a proxy service which fetches the image on its own and sends the result with the required HTTP headers to force the browser to download it instead of opening it directly.
I will see what I can do - but this will only be done when I also add a download option for PhotoSwipe 5, so don't expect anything soon.
Could you please consider adding a thumbnail button in Photoswipe 5? Just like this I searched for a long time to find this function in this plugin.
Could you please consider adding a thumbnail button in Photoswipe 5? Just like this I searched for a long time to find this function in this plugin.
This is not just simple button.
The thumbnail view itself also has to be programmed first which includes a number challenges, like moving the lightbox to the left when the thumbnail view opens and implementing the thumbnail view as well which includes the question what images to use for the thumbnails. Keep in mind that PhotoSwipe will only display links to images on he website - it does not know anything at all about thumbnails. You can even create a lightbox without a thumbnail at all, like here:
https://wordpress-demo.arnowelzel.de/lightbox-with-photoswipe-external-images/
See the text "Click here to open the image." which is a link to an image without thumbnail.
Due to the effort needed to do this and the problems connected with that - sorry, no this will not happen.
But as always: pull requests are welcome - if someone else wants to add this as a function I am happy to add the contribution to the plugin.
Download cross-domain image resources, click download will open a new tab, can it start downloading directly after clicking the button