I am using a plugin that imports the favourites from a youtube channel as posts in wordpress.
It works great and creates posts with the content:
<iframe width="670" height="380" src="http://www.youtube.com/embed/videoid" frameborder="0" allowfullscreen></iframe>
However, there are no options to add embed parameters such as:
&showinfo=0
to the embed parameter.
Thus I am considering loading the content into a variable and running a regular expression on it to add the parameter &showinfo=0 after videoid.
$video = get_the_content();
echo preg_replace('embed/(?:(?!").)*', "$1&showinfo=0", $video);
I have always struggled with regular expressions, I’m sure the above is not really the right expression. Any help or even another suggestion would be greatly appreciated!
You’re close, but you have some syntax wrong.
[^"&]*
means ‘any number of characters that are not double quotes or an ampersand’, the latter character I added just in case your plugin generates a link with some extra parameters in it that you weren’t expecting.