You are here

function hook_media_parse in D7 Media 7.3

Same name and namespace in other branches
  1. 7.4 media.api.php \hook_media_parse()
  2. 7.2 media.api.php \hook_media_parse()

Parses a url or embedded code into a unique URI.

Parameters

string $url: The original URL or embed code to parse.

Return value

array The unique URI for the file, based on its stream wrapper, or NULL.

See also

hook_media_parse_alter()

media_parse_to_file()

media_add_from_url_validate()

1 function implements hook_media_parse()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

media_internet_test_media_parse in modules/media_internet/tests/media_internet_test.module
Implements hook_media_parse().
1 invocation of hook_media_parse()
media_parse_to_uri in ./media.module
This will parse a url or embedded code into a unique URI.

File

./media.api.php, line 21
Hooks provided by the Media module.

Code

function hook_media_parse($url) {

  // Only parse URLs from our website of choice: examplevideo.com
  if (substr($url, 0, 27) == 'http://www.examplevideo.com') {

    // Each video has a 5 digit ID, i.e. http://www.examplevideo.com/12345
    // Grab the ID and use it in our URI.
    $id = substr($url, 28, 33);
    return file_stream_wrapper_uri_normalize('examplevideo://video/' . $id);
  }
}