Data URLs / Content Filtering

I want my users not to embed inline images in the editor.

<img src="data:image/png;base64,iVBORw...g==" alt="Red dot" />

After checking the manual, I realized that there are filters for the attributes of the elements.

However, I could not find anything about filtering attribute values, such as the src attribute for the img element.

I would appreciate if someone would point me in the right direction.

Greetings

Oliver

+4
source share
1 answer

You can use advanced content filtering for this. You can easily block content using the config.disallowedContentconfiguration.

config.disallowedContent = {
    img: {
        match: function( element ) {
            if ( element.name === 'img' && element.attributes.src && String( element.attributes.src ).match( /^data\:/ ) ) {
                return true;
            }
            return false;
        }
    }
};

For more information, contact:

+1

Source: https://habr.com/ru/post/1627008/


All Articles