You are here

function oembed_file_presave in oEmbed 7.0

Same name and namespace in other branches
  1. 8 oembed.file.inc \oembed_file_presave()
  2. 7 oembed.file.inc \oembed_file_presave()

Implements hook_file_presave().

File

./oembed.file.inc, line 63

Code

function oembed_file_presave(stdClass $file) {

  // For new oEmbed files, set the filename to the oEmbed response's title or calculated
  // alt attribute.
  if (empty($file->fid) && isset($file->oembed)) {
    $embed = $file->oembed;
    $file->filename = truncate_utf8(empty($embed['title']) ? oembed_alt_attr($embed) : $embed['title'], 255);
  }
}