Created
March 20, 2023 02:45
-
-
Save Sharifur/9eb95a3ae0c3848fc3a7ca2c658461ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//js function to change iframe markup into a shortcode | |
function iFrameFilterInSummernote(contents){ | |
let rawContents = contents; | |
let matches = rawContents.match(/<iframe(.+)<\/iframe>/); | |
let ifamemarkup = Array.isArray(matches) ? matches[0] : ''; | |
let srcMatches = ifamemarkup.match(/src="(.*?)"/); | |
let ifameSrc = Array.isArray(srcMatches) ? srcMatches[0] : ''; | |
return rawContents.replace(/<iframe(.+)<\/iframe>/, '{iframe} {vsrc}="'+ifameSrc.replace('src="','')+'{/iframe}'); | |
} | |
//php to render shotcode into iframe for frontend | |
function iFrameFilterInSummernoteAndRender($content){ | |
return str_replace(['{iframe}','{vsrc}','{/iframe}'],['<iframe','src',' frameborder="0" height="360" width="640"></iframe>'],$content); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment