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

Error when using lightbox with data:image URLs that are base64 #48

Open
muftaye opened this issue Jan 11, 2023 · 3 comments
Open

Error when using lightbox with data:image URLs that are base64 #48

muftaye opened this issue Jan 11, 2023 · 3 comments

Comments

@muftaye
Copy link

muftaye commented Jan 11, 2023

I get the below error when trying to use the lightbox with data base64 urls. Everything works excepts when clicking on the image, the lightbox does not open and the error below is provided in the console.

      Failed to construct 'URL': Invalid URL

Here is the code I am using. It works fine when I use an actual URL to an image on the server, but not with data base64 URLs.

<a data-remote="data:image/jpeg;base64,/9j/4AAQ..." data-toggle="lightbox" data-gallery="user-gal"> <img src="data:image/jpeg;base64,/9j/4AAQ..." class="img-fluid"> </a>

Does this not support these data URLs? Or am I doing something wrong for this specifically?

@trvswgnr
Copy link
Owner

Currently it uses URL to construct the url, so no that wouldn't be supported currently. Maybe I can add a check for data: and use the raw string. In the meantime maybe you could use the HTML type with an image tag?

<p>
  <a href="#" data-src="<img src='data:image...'>" data-type="html" data-title="Custom HTML" data-toggle="lightbox" data-gallery="custom-html">Custom HTML</a>
</p>

@muftaye
Copy link
Author

muftaye commented Jan 11, 2023

Yea that works too. I think adding the check to not construct the url if its a data url or adding a new data type would both work as well.

@muftaye muftaye closed this as completed Jan 11, 2023
@trvswgnr
Copy link
Owner

Reopening this for feature planning.

@trvswgnr trvswgnr reopened this Jan 13, 2023
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

2 participants