Skip to content

Instantly share code, notes, and snippets.

@tjhole
Created December 1, 2015 11:06
Show Gist options
  • Save tjhole/bfce285083d34df0ccf0 to your computer and use it in GitHub Desktop.
Save tjhole/bfce285083d34df0ccf0 to your computer and use it in GitHub Desktop.
<?php
// get iframe HTML
$iframe = get_field('oembed');
// use preg_match to find iframe src
preg_match('/src="(.+?)"/', $iframe, $matches);
$src = $matches[1];
// add extra params to iframe src
$params = array(
'controls' => 0,
'hd' => 1,
'autohide' => 1
);
$new_src = add_query_arg($params, $src);
$iframe = str_replace($src, $new_src, $iframe);
// add extra attributes to iframe html
$attributes = 'frameborder="0"';
$iframe = str_replace('></iframe>', ' ' . $attributes . '></iframe>', $iframe);
// echo $iframe
echo $iframe;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment