Keep Correct Size Of Embed Video In Tinymce
I want to add embed media in TinyMce with media plugin. When I add an embed video for example with specific size value, when I save the post, the width is not correct. The followin
Solution 1:
I found a solution to my problem, this isn't the clever one but this still works well. I apply the css property to the parent <p>
of the <iframe>
(all iframe are put in <p>
tag)
I use the following function
publiccorrectWidthIframe(html: string) {
let regex = /<p[^>]*>(<iframe*[^>]+(width=*[^height]*height="[0-9]*")[^>]*><\/iframe><\/p>)/g;
return html.replace(regex, (match, p1, p2) => {
let dimension = p2.match(/[0-9]+/g);
letstyle: string = '<p style="max-width:'+dimension.shift()+'px;">'; // only width is wrongreturn style + p1;
});
}
I use this function when i want to create and modify message that contain embedVideo.
Post a Comment for "Keep Correct Size Of Embed Video In Tinymce"