Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Replace Youtube URLS with iframe
// replace youtube urls
if(strpos($page->body, '<p>') !== false) {
$replacement = '<iframe width="444" height="280" src="$1?$2" frameborder="0" allowfullscreen></iframe>';
$page->body = preg_replace('#<p>\s*\?v=([^\s&<]+)([\&amp\;+?].+).*?</p>#iu', $replacement, $page->body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.