You are here

function swftools_image_html_alt in SWF Tools 6.3

Replaces the html_alt string with an image tag when rendering an image playlist.

This is designed so that if the Flash embed fails the user will see the first image from the image playlist, rather than just an empty message.

TODO: Could extend this to substitute thumbnails on audio? Or is that too much!

Parameters

array $options: SWF Tools data array.

Return value

nothing Modifies the array directly.

1 call to swftools_image_html_alt()
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 2216
The primary component of SWF Tools that enables comprehensive media handling.

Code

function swftools_image_html_alt(&$options) {

  // Make sure there is a playlist (not using Flickr etc)
  if ($file = $options['othervars']['playlist_data']['playlist']) {

    // Get the first array element - use array_shift on a copy of the playlist in case there are named keys
    $file = array_shift($file);

    // Get height and width data for the first image
    $info = swftools_get_info($file['filepath']);

    // Initialise an empty array
    $attributes = array();

    // Try to make sure the image height and width don't exceed the player height and width to keep the layout as we expect
    if ($info) {
      $attributes['height'] = $info['height'] > $options['othervars']['height'] ? $options['othervars']['height'] : $info['height'];
      $attributes['width'] = $info['width'] > $options['othervars']['width'] ? $options['othervars']['width'] : $info['width'];
    }

    // Replace html_alt with an image, setting alt text as both alt and title (so when user hovers they see a sensible message)
    $alt = strip_tags(theme('swftools_html_alt', $options));
    $options['othervars']['html_alt'] = theme('image', $file['filepath'], $alt, $alt, $attributes, FALSE);
  }
}