Find embed, add atttribute
Posted: Wed May 12, 2010 3:50 pm
I use the following php to find and retrieve all embed tags. However, I'm wondering if there is a way to add the attribute wmode="opaque" to the tag before returning it...
Essentially, I find the embed and wrap it in a div so I can re-size it, and if there isn't an embed tag, I find an image. However, I want to add the attribute wmode="opaque" before returning the embed. Thanks!
Code: Select all
function show_thumb() {
global $post, $posts;
$thumb = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/(\<embed.*\<\/embed\>)/is', $post->post_content, $matches);
$thumb = $matches [1] [0];
if(empty($thumb)) {
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$thumb = $matches [1] [0];
if(empty($thumb)) {
} else {
return '<div class="thumb"><img src="'.$thumb.'" alt="thumb-'.$post->ID.'" /></div>';
}
} else {
return '<div class="thumb">'.$thumb.'</div>';
}
}