Skip to content
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

Feature Request: Allow download url to be overridden. #129

Open
h5aaimtron opened this issue Mar 9, 2022 · 4 comments
Open

Feature Request: Allow download url to be overridden. #129

h5aaimtron opened this issue Mar 9, 2022 · 4 comments

Comments

@h5aaimtron
Copy link
Contributor

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.

@h5aaimtron
Copy link
Contributor Author

h5aaimtron commented Mar 9, 2022

@themyth92
Pull Request

@inaitana
Copy link

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'.

@h5aaimtron
Copy link
Contributor Author

h5aaimtron commented May 13, 2022

@themyth92

The change to make the property in the interface optional would be:

downloadUrl?: string

The rest of the code should already work.

@AXeL-dev
Copy link
Contributor

Pull request created: #136 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants