// Get Embed - gets embed Code from custom field - Use: lom_get_embed
/*
Parameters:
$key = Custom field key eg. "embed"
$width = Set width manually without using $type
$height = Set height manually without using $type
*/
function lom_get_embed($key = 'embed', $width, $height, $class = 'video', $id = null) {
if(empty($id))
{
global $post;
$id = $post->ID;
}
$custom_field = get_post_meta($id, $key, true);
if ($custom_field) :
$org_width = $width;
$org_height = $height;
// Get custom width and height
$custom_width = get_post_meta($id, 'width', true);
$custom_height = get_post_meta($id, 'height', true);
// Set values: width="XXX", height="XXX"
if ( !$custom_width ) $width = 'width="'.$width.'"'; else $width = 'width="'.$custom_width.'"';
if ( !$custom_height ) $height = 'height="'.$height.'"'; else $height = 'height="'.$custom_height.'"';
$custom_field = stripslashes($custom_field);
$custom_field = preg_replace( '/width="([0-9]*)"/' , $width , $custom_field );
$custom_field = preg_replace( '/height="([0-9]*)"/' , $height , $custom_field );
// Set values: width:XXXpx, height:XXXpx
if ( !$custom_width ) $width = 'width:'.$org_width.'px'; else $width = 'width:'.$custom_width.'px';
if ( !$custom_height ) $height = 'height:'.$org_height.'px'; else $height = 'height:'.$custom_height.'px';
$custom_field = stripslashes($custom_field);
$custom_field = preg_replace( '/width:([0-9]*)px/' , $width , $custom_field );
$custom_field = preg_replace( '/height:([0-9]*)px/' , $height , $custom_field );
// Suckerfish menu hack
$custom_field = str_replace('<embed ','<param name="wmode" value="transparent"></param><embed wmode="transparent" ',$custom_field);
$output = '';
$output .= '<div class="'. $class .'">' . $custom_field . '</div>';
return $output;
endif;
}