tinymcetinymce-5tinymce-plugins

TinyMce picture tag wrapper


In out CMS we put every image inside "picture" tag like this:

<picture>
    <source srcset="image.webp" type="image/webp"> <img class="_img_resp" 
     src="image.jpe" alt="Image"> 
</picture>

But tiny wraps every picture tag inside "p" I see that some tags like: "ul", "div", "h2" are wrappers itself without additional "p" So, can i made "picture" tag a new custom wrapper? I dont need deleting root "p" tag from all content

I use tinymcy 5.10


Solution

  • Ok, i solved it with this

    custom_elements: 'picture',
    valid_children: 'picture[source|img]',
    formats: {
       'custom_picture': {block: 'picture', selector: 'picture', merge_siblings: true, wrapper: true},
             }
    

    Not clear, but it works