Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
onWfGetCustomEmbedData example
public function onWfGetCustomEmbedData($url = '')
{
$expression = 'http(s)://(www\.)myembed\.com/(.*)id=(.*)';
$data = array(
'width' => '560',
'height'=> '315',
'src' => '',
'allow' => 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture allowfullscreen',
);
if (empty($url)) {
$data['expression'] = $expression;
return array(
'myembed' => $data
);
}
preg_match('#' . $expression . '#i', $url, $matches);
if ($matches) {
$data['src'] = 'https://www.myembed.com/embed/?id=' . $matches[5];
return array(
'myembed' => $data
);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment