Use Base64 String from URL in src tag of image

后端 未结 3 2140
别跟我提以往
别跟我提以往 2021-02-06 04:09

I have an service which returns the base64 version of an image. Now i want to use the base64 string in the src tag of an img. The service offers the ba

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 04:48

    It is not working because you are treating a page featuring a Data URL string, as if were just another type of external link-able image asset. Unfortunately linking to an external asset works for image files, but Data URLs are meant as an alternative to an external link, and thus does not work in the same way.

    In short, to display an image making use of a data URL string, you need put the actual data URL string as the src= value, in your case for example:

    
    

    Examples

    Example HTML from Masinter, 1998 RFC 2397 - The "data" URL scheme:

    Larry

提交回复
热议问题