diff --git a/media_vimeo.install b/media_vimeo.install index c6b9ded..2b679b4 100644 --- a/media_vimeo.install +++ b/media_vimeo.install @@ -22,4 +22,17 @@ function media_vimeo_uninstall() { media_vimeo_variable_del($variable); } return array(array('success' => TRUE, 'query' => "Deleted all variables in the Media: Vimeo namespace.")); -} \ No newline at end of file +} + +/** + * Update Media Vimeo files to the new video file_entity type. + */ +function media_vimeo_update_7101() { + $video_type = file_type_load('video'); + $video_type->mimetypes[] = 'video/vimeo'; + // maybe also add stream if is not there already? + file_type_save($video_type); + + // Update existing files. + db_query("UPDATE {file_managed} SET type = 'video' WHERE type = 'undefined' AND filemime = 'video/vimeo'"); +} diff --git a/media_vimeo.module b/media_vimeo.module index 882baad..fe838bc 100644 --- a/media_vimeo.module +++ b/media_vimeo.module @@ -122,3 +122,19 @@ function media_vimeo_ctools_plugin_api($owner, $api) { return array('version' => $api_versions[$owner][$api]); } } + + /** + * Implements hook_file_mimetype_mapping_alter(). + */ +function media_vimeo_file_mimetype_mapping_alter(&$mapping) { + $mapping['mimetypes'][] = 'video/vimeo'; +} + +/* + * Implements hook_file_default_types_alter(). + * + * Adds the video/vimeo fake mimetype to video files. + */ +function media_vimeo_file_default_types_alter(&$types) { + $types['video']->mimetypes[] = 'video/vimeo'; +}