You are here

function angular_media_oembed_response_alter in CKEditor Widgets 7

Alters an oEmbed response.

Parameters

array $response: oEmbed response data.

File

./angular_media.module, line 144
Implementation of angular_media.module.

Code

function angular_media_oembed_response_alter(&$response) {
  if ($response['provider'] == 'default:youtube' && !empty($response['thumbnail_url'])) {
    $regex = '/(.*?(img\\.youtube\\.com|i\\.ytimg\\.com)\\/vi\\/(.*?)\\/)/i';
    preg_match($regex, $response['thumbnail_url'], $matches);

    // If we have a match, lets add the max res version of the thumb
    if (count($matches) > 0) {
      $response['thumbnail_url'] = $matches[1] . 'maxresdefault.jpg';
    }
  }
}