You are here

function oembed_file_presave in oEmbed 8

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

Implements hook_file_presave().

File

./oembed.file.inc, line 69

Code

function oembed_file_presave($file) {

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

  // Fetch image dimensions.
  oembed_metadata_fetch_image_dimensions($file);
}