Skip to content

Commit

Permalink
use alter hook to workaround embed.ly's non-standard schemes. http://…
Browse files Browse the repository at this point in the history
  • Loading branch information
bangpound committed Jan 25, 2011
1 parent 6c208f7 commit 5960d90
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions oembedembedly.module
Expand Up @@ -79,4 +79,29 @@ function oembedembedly_admin() {
'#description' => t('This option defines whether providers should be enabled by default or not.'),
);
return system_settings_form($form);
}

/**
* Implement hook_oembedprovider_alter().
*
* This is to workaround embed.ly's nonstandard oembed descriptions.
*/
function oembedembedly_oembedprovider_alter(&$providers) {

// oEmbed standard dictates that wildcards can only be used for subdomains in
// URL schemes. embed.ly breaks this rule, which causes unmatchable domains.
foreach ($providers as $host => $patterns) {

// When the first character is * such as *youtube.com.
if (strpos($host, '*') === 0) {
$new_host = drupal_substr($host, 1);
if (!empty($providers[$new_host])) {
$providers[$new_host] = array_merge($providers[$new_host], $patterns);
}
else {
$providers[$new_host] = $patterns;
}
unset($providers[$host]);
}
}
}

0 comments on commit 5960d90

Please sign in to comment.