function swftools_set_size in SWF Tools 6.3
Same name and namespace in other branches
- 6.2 swftools.module \swftools_set_size()
Helper function to set the size of the swf content in to $options['othervars']['height'] and ['width']
Parameters
array &$options: Data array that is being assembled by SWF Tools.
Return value
nothing Function operates by reference.
1 call to swftools_set_size()
- swf in ./
swftools.module - Processes a file, or an array of files, and returns the relevant mark-up to render a Flash based player.
File
- ./
swftools.module, line 1393 - The primary component of SWF Tools that enables comprehensive media handling.
Code
function swftools_set_size(&$options) {
// We use these defaults to filter arrays for their height and width, and assign a fallback value
$defaults = array(
'height' => '100%',
'width' => '100%',
);
// If height and width are already set then just return
if (count(array_intersect_key($options['othervars'], $defaults)) == 2) {
return;
}
// See if we can get height and width from flashvars
$try = array_intersect_key($options['flashvars'], $defaults);
$options['othervars'] += $try;
// See if we can get height and width from player
$try = array_intersect_key($options['resolved_methods']['player'], $defaults);
$options['othervars'] += $try;
// If we have a height and width now then return
if (count(array_intersect_key($options['othervars'], $defaults)) == 2) {
return;
}
// Try and get size from the file to be embedded, but preserve height or width if just one was set
$info = swftools_get_info($options['othervars']['filepath']);
// If sizes were retrieved then use them
if ($info) {
$try = array_intersect_key($info, $defaults);
$options['othervars'] += $try;
}
// And if all else fails, assign 100%
$options['othervars'] += $defaults;
}