function swftools_set_size in SWF Tools 6.2
Same name and namespace in other branches
- 6.3 swftools.module \swftools_set_size()
Helper function to set the size of the swf content in to $vars->params
Parameters
$vars: $vars arrays that is being assembled by SWF Tools.
$player: The array of player data for the player that will be used.
Return value
Nothing - function directly sets $vars.
1 call to swftools_set_size()
- swf in ./
swftools.module - Return output, which might be embed markup, or pre-flash markup that includes the appropriate jQuery added to the <head>
File
- ./
swftools.module, line 1750
Code
function swftools_set_size(&$vars, $player = array()) {
// Not a pretty piece of code, but should be ok for the moment. We are
// purposefully passing the width and height
// if we have them. Unsure if this will cause problems with some players.
// It's an ugly piece of code, but will remain in this form until a clearer
// solution arises.
//
// It may be that, in hook_swftools_methods, the flash player indicates that
// it *want* certain values copied b/t params and flashvars.
// The code below was patch to fix notice errors, but it broke flash node autodetect
// Flash node has been patched to fix this by changing zero height / width to null
// TODO : Is it really necessary to set the height and width in to the flashvars?
// If flashvars are empty, but params are set, populate flashvars with params
if (empty($vars->flashvars['width']) && empty($vars->flashvars['height'])) {
if (!empty($vars->params['width']) && !empty($vars->params['height'])) {
$vars->flashvars['width'] = $vars->params['width'];
$vars->flashvars['height'] = $vars->params['height'];
return;
}
}
// If params are empty, but flashvars are set, populate params with flashvars
if (empty($vars->params['width']) && empty($vars->params['height'])) {
if (!empty($vars->flashvars['width']) && !empty($vars->flashvars['height'])) {
$vars->params['width'] = $vars->flashvars['width'];
$vars->params['height'] = $vars->flashvars['height'];
return;
}
}
// If still empty we try and get them from the file to be embedded
if (empty($vars->params['height']) || empty($vars->params['width'])) {
$info = swftools_get_info($vars->params['src_path']);
if ($info) {
$vars->params['height'] = $info['height'];
$vars->params['width'] = $info['width'];
return;
}
}
// If we STILL don't have a width after all this, try to use fallback player defaults
if (empty($vars->params['width']) && isset($player['width'])) {
$vars->params['width'] = $player['width'];
}
// If we STILL don't have a height after all this, try to use fallback player defaults
if (empty($vars->params['height']) && isset($player['height'])) {
$vars->params['height'] = $player['height'];
}
}