JPGs and URL.createObjectURL()
Bennett Upfield
Posted on February 17, 2022
CreatingImageUrls
Lets say for some abstract reason completely unrelated to this other post of mine (Hmmm) you have a javascript File object that is of image and you want to display it on your site instead of simply pulling an url for and image. Now if you had this image you could use this cool Url method, URL.createObjectURL(). The code would be
const interpretedImage = URL.createObjectURL(imgFile);
And to use this created url image on your html image element use the interpretedImage variable as the src. However do make sure the file is unnamed as the name of the file will appear in the image if you name it.
💖 💪 🙅 🚩
Bennett Upfield
Posted on February 17, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
javascript Navigating the World of JavaScript: A Mechanical Engineer's Perspective on Learning and Challenges
November 25, 2024