1 image.module image_file_presave($file)

Implements hook_file_presave().

Set the dimensions in the "metadata" property used by File entities.

File

core/modules/image/image.module, line 1381
Exposes global functionality for creating image styles.

Code

function image_file_presave($file) {
  if (image_is_svg($file->uri) && isset($file->metadata)) {
    $svg_dimensions = image_get_svg_dimensions($file->uri);
    if ($svg_dimensions) {
      $file->metadata['width'] = $svg_dimensions['width'];
      $file->metadata['height'] = $svg_dimensions['height'];
    }
  }
}