Created
March 9, 2011 12:14
-
-
Save peteboere/862097 to your computer and use it in GitHub Desktop.
function for generating swf object html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_swf ( $url, $attributes = array(), $params = array(), $alt_content = null ) { | |
$attributes = is_array( $attributes ) ? $attributes : array(); | |
$attributes[ 'width' ] = is_numeric( $attributes[ 'width' ] ) ? $attributes[ 'width' ] : 100; | |
$attributes[ 'height' ] = is_numeric( $attributes[ 'height' ] ) ? $attributes[ 'height' ] : 100; | |
$attributes_fmt = " %s=\"%s\""; | |
$attributes_str = ''; | |
foreach ( $attributes as $name => $value ) { | |
$attributes_str .= sprintf( $attributes_fmt, $name, $value ); | |
} | |
$params_fmt = "<param name=\"%s\" value=\"%s\" />\n"; | |
$params_str = ''; | |
if ( $params ) { | |
foreach ( $params as $name => $value ) { | |
if ( is_array( $value ) ) { | |
$value = http_build_query( $value ); | |
} | |
$params_str .= sprintf( $params_fmt, $name, urlencode( $value ) ); | |
} | |
} | |
$alt_content = isset( $alt_content ) ? $alt_content : | |
'<a href="http://www.adobe.com/go/getflashplayer">Get Adobe Flash player</a>'; | |
$ie_movie = sprintf( $params_fmt, 'movie', $url ); | |
return <<<TPL | |
<!--[if !IE]>--> | |
<object type="application/x-shockwave-flash" data="$url"$attributes_str> | |
<!--<![endif]--> | |
<!--[if IE]> | |
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"$attributes_str> | |
$ie_movie<![endif]--> | |
$params_str$alt_content | |
</object>\n | |
TPL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment