You are here

protected function SWFObject::getDimension in SWF Embed 7

Same name and namespace in other branches
  1. 6 swfembed.module \SWFObject::getDimension()

Get a single dimension for this SWF file.

If an explicitly dimension is specified, that will be used. If not, the dimensions will be derived from the SWF file, if possible.

If the dimension is not explicitly specified, it will be specified by this function.

Parameters

$key: The dimension to use, either height or width.

Return value

The value in pixels of that dimension.

2 calls to SWFObject::getDimension()
SWFObject::getHeight in ./swfembed.module
Returns the height the SWF file should use.
SWFObject::getWidth in ./swfembed.module
Returns the width the SWF file should use.

File

./swfembed.module, line 285
The main file for swfembed.

Class

SWFObject
Generic data object for describing an SWF configuration.

Code

protected function getDimension($key) {
  $derived = array();
  if (empty($this->dimensions[$key])) {
    list($derived['width'], $derived['width']) = getimagesize($this
      ->getFlashObject());

    // We only want to bother analyzing the image once, but if a dimension
    // has already been set explicitly then we don't want to overwrite it.
    foreach (array(
      'height',
      'width',
    ) as $field) {
      if (empty($this->dimensions[$field])) {
        $this->dimensions[$field] = $derived[$field];
      }
    }
  }
  return $this->dimensions[$key];
}