You are here

function swftools_get_media_url in SWF Tools 6.2

Same name and namespace in other branches
  1. 5 swftools.module \swftools_get_media_url()
  2. 6 swftools.module \swftools_get_media_url()

Resolve a path to a full url, either on the local file system, or at a remote address if the swftools_media_url variable has been set. If the path describes a file, is local and the swftools_check_media variable is set then check if the file exists. The path must be relative to the webroot.

Parameters

$path: The file path to check.

$is_file: Optional flag to indicate that the path points to a file in which case local files can be tested to see if they exist (defaults to TRUE). If set to FALSE then it indicates the path doesn't refer to a file and it won't be tested.

Return value

A string with the complete url to the file, either locally or using the remote path, or FALSE if the local file doesn't exist

11 calls to swftools_get_media_url()
flowplayer3_swftools_embed in flowplayer3/flowplayer3.module
flowplayer3_swftools_flashvars in flowplayer3/flowplayer3.module
Implementation of swftools_flashvars hook(). Note that $methods and $vars are passed by reference, so the player module can manipulate them directly if necessary.
flowplayer_flowplayer_mediaplayer_swftools_playlist in flowplayer/flowplayer.module
flowplayer_swftools_flashvars in flowplayer/flowplayer.module
Implementation of swftools_flashvars hook. Return an array of flashvars.
imagerotator_swftools_flashvars in imagerotator/imagerotator.module
Implementation of swftools_flashvars hook. Return an array of flashvars.

... See full list

File

./swftools.module, line 793

Code

function swftools_get_media_url($path, $is_file = TRUE) {

  // Retrieve swftools_media_url to see if a remote path has been set
  $media_url = trim(variable_get('swftools_media_url', ''));

  // If a remote path is set simply build the appropriate path and return
  if ($media_url) {
    return $media_url . '/' . $path;
  }

  // If media checking is active, and the path is a file, check to see if it actually exists
  if (variable_get('swftools_check_media', TRUE) && $is_file) {

    // If the file doesn't exist, set an error message and return FALSE to indicate failure
    if (!file_exists($path)) {
      drupal_set_message(t('Could not display the flash because %path does not appear to exist.', array(
        '%path' => $path,
      )), 'error');
      return FALSE;
    }
  }

  // Return the path
  return file_create_url($path);
}