You are here

function scald_flash_scald_prerender in Scald: Media Management made easy 7

Implements hook_scald_prerender.

File

modules/providers/scald_flash/scald_flash.module, line 97
Defines a flash provider for Scald.

Code

function scald_flash_scald_prerender($atom, $context, $options, $mode) {
  if ($mode == 'atom') {
    if ($context === 'sdl_library_item') {
      $scald_thumbnail = field_get_items('scald_atom', $atom, 'scald_thumbnail');
      if (empty($scald_thumbnail)) {
        $atom->rendered->thumbnail_transcoded_url = file_create_url($atom->thumbnail_source);
      }
    }
    else {
      $flash_width = 480;
      $flash_height = 365;
      $scald_width = field_get_items('scald_atom', $atom, 'scald_width');
      if (!empty($scald_width)) {
        $flash_width = $scald_width[0]['value'];
      }
      $scald_height = field_get_items('scald_atom', $atom, 'scald_height');
      if (!empty($scald_height)) {
        $flash_height = $scald_height[0]['value'];
      }

      // Allow context configuration to override flash dimension variables.
      $context_config = scald_context_config_load($context);
      if (!empty($context_config->data['width']) && !empty($context_config->data['height'])) {
        $flash_width = $context_config->data['width'];
        $flash_height = $context_config->data['height'];
      }
      $atom->rendered->player = theme('scald_flash_object', array(
        'vars' => array(
          'flash_uri' => $atom->rendered->file_source_url,
          'flash_width' => $flash_width,
          'flash_height' => $flash_height,
          'thumbnail' => $atom->thumbnail_source,
        ),
      ));
    }
  }
}