Open h5aaimtron opened 2 years ago
@themyth92 Pull Request
This pull request introduced a potential breaking change, by making downloadUrl mandatory for IAlbum.
I know it's my fault for hard typing the variable (first argument to lightbox.open) to IAlbum[] when declaring it, whereas in your example it's declared as generic, but I can't see a reason why we shouldn't, since open() actually takes an IAlbum[] as its first argument.
And I really think downloadUrl should be optional.
Code:
const gallery: IAlbum[] = [];
for (const file of files) {
gallery.push({
src: environment.static_url + file.filepath,
caption: file.description,
thumb: environment.static_url + file.filepath
});
}
this.lightbox.open(gallery, 0);
Error:
TS2345: Argument of type '{ src: string; caption: string; thumb: string; }' is not assignable to parameter of type 'IAlbum'.
Property 'downloadUrl' is missing in type '{ src: string; caption: string; thumb: string; }' but required in type 'IAlbum'.
@themyth92
The change to make the property in the interface optional would be:
downloadUrl?: string
The rest of the code should already work.
Pull request created: https://github.com/themyth92/ngx-lightbox/pull/136 .
Right now the package attempts to pull the src passed in on the image object and trigger a save, however; this doesn't work when images are hosted on separate origins due to CORS. It would be a great feature if you can add a property, say "downloadUrl" that if populated, is used instead of the src value on download click. This allows users to proxy download when necessary while still loading the original source without a proxy.