You are here

function emaudio_zzz_custom_url_data in Embedded Media Field 5

1 call to emaudio_zzz_custom_url_data()
emaudio_zzz_custom_url_rss in contrib/emaudio/providers/zzz_custom_url.inc
hook emfield_PROVIDER_rss

File

contrib/emaudio/providers/zzz_custom_url.inc, line 53

Code

function emaudio_zzz_custom_url_data($field, $item) {
  $data = array();

  // adding the version control
  $data['emaudio_zzz_custom_url_data_version'] = 1;

  // attempt to get info from headers
  $response = emfield_request_header('zzz_custom_url', $item['embed']);
  if ($response->code == 200) {
    $data['url'] = $item['embed'];
    $data['size'] = $response->headers['Content-Length'];
    $data['mime'] = $response->headers['Content-Type'];
  }

  // @todo replace ['type'] with converted mime info if available
  $types = _emaudio_zzz_custom_url_implode_types();
  $regex = '@\\.(' . $types . ')@i';
  if (preg_match($regex, $item['embed'], $matches)) {
    $data['type'] = $matches[1];
  }
  return $data;
}