]*>(.*?)?\/iframe>/i', array($this, 'trust_url_match'), $html); $html = preg_replace_callback('/]*>(.*?)?\/iframe>/i', array($this, 'trust_url_match'), $html); //$html = preg_replace('##i', '', $html); } return $html; } public function trust_url_match($matches) { $str = $matches[0]; if( $matches[1] ){ $str = preg_replace('##i', '', $str); } return $str; } /** * * @param string $html * @param HTMLPurifier_Config $config * @param HTMLPurifier_Context $context * @return string */ public function postFilter($html, $config, $context) { $post_regex = '#]+?)>#'; return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html); } /** * * @param array $matches * @return string */ protected function postFilterCallback($matches) { // Domain Whitelist $youTubeMatch = preg_match('#src="https?://www.youtube(-nocookie)?.com/#i', $matches[1]); $vimeoMatch = preg_match('#src="https?://player.vimeo.com/#i', $matches[1]); if ($youTubeMatch || $vimeoMatch) { $extra = ' frameborder="0"'; if ($youTubeMatch) { $extra .= ' allowfullscreen'; } elseif ($vimeoMatch) { $extra .= ' webkitAllowFullScreen mozallowfullscreen allowFullScreen'; } return ''; } else { return ''; } } } } ?>