Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use data URI scheme to embed pictures in a web page

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how to use data URI scheme to embed pictures in the web page. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Data URI scheme allows us to use inline (inline-code) to include data in web pages, which can be used in Html, CSS, Javascript, etc.

Data URI scheme is often used to embed pictures into web pages, using the following:

鹤冲天的头像(您的浏览器不支持 data URI scheme,图片无法显示)

The data URI scheme format is as follows:

Data: [] [; base64]

This format is relatively simple, and if you compare it, you can see that the img above is a jpg image encoded in base64.

Embed this img into this page and display it as follows:

In addition to base64 encoding, you can also use hexadecimal URL encoding in the form of% xx, as follows:

鹤冲天的头像(您的浏览器不支持 data URI scheme,图片无法显示)

_ fcksavedurl= "" data:image/jpeg,%FF%D8%FF%E0JFIFq/* omitted a lot of data here * /% F7*q%D6Q%EDt%F6%EE%7F%FF%D9 "/ >" _ fcksavedurl= "" data:image/jpeg,%FF%D8%FF%E0JFIFq/* omitted many data here * /% F7*q%D6Q%EDt%F6%EE%7F%FF%D9 "/ >"

Generate picture data

According to the above format, we can write a Mini Program to generate, but we do not need to go to so much trouble, there are many websites offering this (free) service.

Here are a few:

1. Http://dataurl.sveinbjorn.org/dataurlmaker

Provide preview, easy to copy.

2. Http://websemantics.co.uk/online_tools/image_to_data_uri_convertor/

Provide a preview, but also generate the corresponding CSS URI data.

3. Http://software.hixie.ch/utilities/cgi/data/data

Tip: generation is not limited to image data, you can use three ways (see figure 1, 2, 3 below), you can specify the encoding method, but the interface is not friendly.

Used in group presentations

Click the insert / Edit Picture button:

Pop up the following window, use any of the above URLs, generate picture data, copy and paste into the picture address text box:

Click insert to OK, as shown below:

This is the end of the article on "how to use data URI scheme to embed pictures in the web page". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report