You are here

function svg_image_file_presave in Svg Image 7

Implements hook_file_presave().

Set the dimensions in the "metadata" property used by File Entity module.

File

./svg_image.module, line 38

Code

function svg_image_file_presave($file) {
  if (svg_image_is_svg($file->uri) && isset($file->metadata)) {
    $svg_dimensions = svg_image_get_dimensions($file->uri);
    if ($svg_dimensions) {
      $file->metadata['width'] = $svg_dimensions['width'];
      $file->metadata['height'] = $svg_dimensions['height'];
    }
  }
}