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

Give image mime type in images array #66

Open
tremby opened this issue Aug 14, 2018 · 3 comments
Open

Give image mime type in images array #66

tremby opened this issue Aug 14, 2018 · 3 comments

Comments

@tremby
Copy link

tremby commented Aug 14, 2018

It'd be useful for building <picture> elements to have each image's mime type along with its other data, for use in the type attribute of the <source> element.

@DotIN13
Copy link

DotIN13 commented Mar 6, 2021

Simply use "image/" + ImageObj.src.split(".").pop()

@tremby
Copy link
Author

tremby commented Mar 8, 2021

  • Images' filenames do not always have a type extension
  • Something that looks like a filetype extension may not really be its filetype. You might get this for example if automatically compressing lossless originals to a suitable compressed format.
  • Not all common filetype extensions map exactly to mime types as your code would rely on them to. .jpg is the most common one for image/jpeg (and then there are also .jfif, .pjpeg, .pjp), and .svg for application/svg+xml for example.

@DotIN13
Copy link

DotIN13 commented Mar 8, 2021

  • Images' filenames do not always have a type extension
  • Something that looks like a filetype extension may not really be its filetype. You might get this for example if automatically compressing lossless originals to a suitable compressed format.
  • Not all common filetype extensions map exactly to mime types as your code would rely on them to. .jpg is the most common one for image/jpeg (and then there are also .jfif, .pjpeg, .pjp), and .svg for application/svg+xml for example.

You are correct with the said issues. Sorry I did not notive them as I personally only use webp and avif. This probably has to be fixed by the loader.

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