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

Support for Schema-relative URL for remote images #235

Open
saneef opened this issue Jul 17, 2024 · 3 comments
Open

Support for Schema-relative URL for remote images #235

saneef opened this issue Jul 17, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@saneef
Copy link

saneef commented Jul 17, 2024

The schema-relative or protocol relative URLs are common while porting old sites to Eleventy.

<img
  alt="A head of a tiger"
  src="//upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg"
>

Presently, when using such URL, new Image() gives the error:

Error: ENOENT: no such file or directory, stat '//upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg'

Is adding support for schema-relative URLs useful for our users?

See: saneef/eleventy-plugin-img2picture#27

@zachleat
Copy link
Member

zachleat commented Jan 3, 2025

Relative to what? Should we make an opinionated choice here and assume https? (I’d be on board with that)

Notably, new URL("//upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg") throws an error.

@zachleat zachleat added the enhancement New feature or request label Jan 3, 2025
@saneef
Copy link
Author

saneef commented Jan 4, 2025

Yes, assuming https looks sensible and safer approach.

@saneef
Copy link
Author

saneef commented Jan 4, 2025

It got me thinking, should this be actually part of the elevent-img. Something that new URL() would not accept as valid?

Can it be a separate utility or a plugin that people can use before eleventy-img?

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

No branches or pull requests

2 participants