function hook_media_parse_alter in D7 Media 7.3
Same name and namespace in other branches
- 7.4 media.api.php \hook_media_parse_alter()
- 7.2 media.api.php \hook_media_parse_alter()
Alters the parsing of urls and embedded codes into unique URIs.
Parameters
string $success: The unique URI for the file, based on its stream wrapper, or NULL.
array $context: A nested array of contextual information containing the following keys:
- url: The original URL or embed code to parse.
- module: The name of the module which is attempting to parse the url or embedded code into a unique URI.
See also
hook_media_browser_plugin_info()
media_get_browser_plugin_info()
1 invocation of hook_media_parse_alter()
- media_parse_to_uri in ./
media.module - This will parse a url or embedded code into a unique URI.
File
- ./
media.api.php, line 46 - Hooks provided by the Media module.
Code
function hook_media_parse_alter(&$success, $context) {
$url = $context['url'];
$url_info = parse_url($url);
// Restrict users to only embedding secure links.
if ($url_info['scheme'] != 'https') {
$success = NULL;
}
// Use a custom handler for detecting YouTube videos.
if ($context['module' == 'media_youtube']) {
$handler = new CustomYouTubeHandler($url);
$success = $handler
->parse($url);
}
}