GetmeUK / ContentTools

A JS library for building WYSIWYG editors for HTML content.
http://getcontenttools.com
MIT License
3.95k stars 395 forks source link

Adding custom attributes to image tag #451

Closed richardpeng closed 6 years ago

richardpeng commented 6 years ago

I'm creating an image with the following code, but the generated image doesn't include the data-image-id attribute.

        image.url,
        image.size,
        {
          'data-image-id': image.id,
          'data-ce-max-width': image.size[0]
        });

I've tried adding data-image-id to the RESTRICTED_ATTRIBUTES like this but it didn't help:

ContentTools.RESTRICTED_ATTRIBUTES['img'].push('data-image-id')

How do I add additional attributes to a tag?

anthonyjb commented 6 years ago

Hi @richardpeng any chance you can provide me with a full example, from the code above I can't see how you're creating an image? is this in the image handler or are you initializing the Image element class?