function oembed_metadata_fetch_image_dimensions in oEmbed 8
Same name and namespace in other branches
- 7 oembed.file.inc \oembed_metadata_fetch_image_dimensions()
Fetch the dimensions of an image and store them in the file metadata array.
2 calls to oembed_metadata_fetch_image_dimensions()
- oembed_file_load in ./
oembed.file.inc - Implements hook_file_load().
- oembed_file_presave in ./
oembed.file.inc - Implements hook_file_presave().
File
- ./
oembed.file.inc, line 117
Code
function oembed_metadata_fetch_image_dimensions($file) {
$scheme = file_uri_scheme($file->uri);
if ($scheme != 'oembed') {
return;
}
// Do not bother proceeding if this file does not have an image mime type.
if (file_entity_file_get_mimetype_type($file) != 'image') {
return;
}
// We have a non-empty image file.
$embed = $file->metadata['oembed'];
if ($embed && $embed['type'] == 'photo' && !empty($embed['width']) && !empty($embed['height'])) {
$file->metadata['width'] = $embed['width'];
$file->metadata['height'] = $embed['height'];
}
else {
// Fallback to NULL values.
$file->metadata['width'] = NULL;
$file->metadata['height'] = NULL;
}
}