0

Can I define the base64 of an image in a class in the Stylesheet and use that class in the tag? Dynamic fonts works pretty much like this, but wondering if I can do the same for image also.

The real usecase is to load an HTML into a WYSIWYG editor with Data URI, and yet avoid repeating the binary content.

A simple gist is like:

CSS

.mylogo{
content: base64;
}

HTML

<img class="mylogo" height="" weight="">

I need to have height and weight etc attributes in the Img itself so that the WYSIWYG editors can resize image etc.

Syam Pillai
  • 4,967
  • 2
  • 26
  • 42
Nishant
  • 20,354
  • 18
  • 69
  • 101
  • 1
    `img` is a self-closing tag and therefore has no inner content. You cannot use `content` to manipulate it. Also `content` will not even work in normal tags. It's only for pseudo elements AFAIK - see test: https://jsfiddle.net/azizn/2rdd4mm4/ – Aziz Aug 18 '16 at 14:00
  • To add to what @Aziz mentioned; you CAN use base64 for `background-image`. See: https://css-tricks.com/data-uris/ – Robert Aug 18 '16 at 14:02
  • You can set its background-image to a dataURI, but then why use an img – Kaiido Aug 18 '16 at 14:02

0 Answers0