media.install 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the Media module.
  5. */
  6. define('MEDIA_UPDATE_RECORDS_ON_INSTALL', 200);
  7. /**
  8. * Implements hook_schema().
  9. */
  10. function media_schema() {
  11. $schema['media_type'] = array(
  12. 'description' => 'Stores the settings for media types.',
  13. 'fields' => array(
  14. 'name' => array(
  15. 'description' => 'The machine name of the media type.',
  16. 'type' => 'varchar',
  17. 'length' => 255,
  18. 'not null' => TRUE,
  19. 'default' => '',
  20. ),
  21. 'label' => array(
  22. 'description' => 'The label of the media type.',
  23. 'type' => 'varchar',
  24. 'length' => 255,
  25. 'not null' => TRUE,
  26. 'default' => '',
  27. ),
  28. 'base' => array(
  29. 'description' => 'If this is a base type (i.e. cannot be deleted)',
  30. 'type' => 'int',
  31. 'not null' => TRUE,
  32. 'default' => 0,
  33. 'size' => 'tiny',
  34. ),
  35. 'weight' => array(
  36. 'description' => 'Weight of media type. Determines which one wins when claiming a piece of media (first wins)',
  37. 'type' => 'int',
  38. 'not null' => TRUE,
  39. 'default' => 0,
  40. 'size' => 'normal',
  41. ),
  42. 'type_callback' => array(
  43. 'description' => 'Callback to determine if provided media is of this type.',
  44. 'type' => 'varchar',
  45. 'length' => 255,
  46. 'not null' => FALSE,
  47. 'default' => '',
  48. ),
  49. 'type_callback_args' => array(
  50. 'type' => 'text',
  51. 'not null' => FALSE,
  52. 'size' => 'big',
  53. 'serialize' => TRUE,
  54. 'description' => 'A serialized array of name value pairs that will be passed to the callback function',
  55. ),
  56. ),
  57. 'primary key' => array('name'),
  58. );
  59. $schema['media_list_type'] = array(
  60. 'description' => 'Stores the user preference for whether to list as table or images.',
  61. 'fields' => array(
  62. 'uid' => array(
  63. 'description' => 'The {user}.uid of the user.',
  64. 'type' => 'int',
  65. 'unsigned' => TRUE,
  66. 'not null' => TRUE,
  67. 'default' => 0,
  68. ),
  69. 'type' => array(
  70. 'description' => 'The type of display (table or images).',
  71. 'type' => 'varchar',
  72. 'length' => 32,
  73. 'not null' => TRUE,
  74. 'default' => '',
  75. ),
  76. ),
  77. 'primary key' => array('uid'),
  78. );
  79. $schema['media_filter_usage'] = array(
  80. 'description' => 'Stores fids that have been included in the media tag in formatted textareas.',
  81. 'fields' => array(
  82. 'fid' => array(
  83. 'description' => 'The media {file_managed}.fid.',
  84. 'type' => 'int',
  85. 'unsigned' => TRUE,
  86. 'not null' => TRUE,
  87. 'default' => 0,
  88. ),
  89. 'timestamp' => array(
  90. 'description' => 'The timestamp the fid was last recorded by media_filter()',
  91. 'type' => 'int',
  92. 'not null' => TRUE,
  93. 'default' => 0,
  94. ),
  95. ),
  96. 'foreign keys' => array(
  97. 'file_managed' => array(
  98. 'table' => 'file_managed',
  99. 'columns' => array('fid' => 'fid'),
  100. ),
  101. ),
  102. 'primary key' => array('fid'),
  103. 'indexes' => array(
  104. 'timestamp' => array('timestamp'),
  105. ),
  106. );
  107. $schema['cache_media_xml'] = drupal_get_schema_unprocessed('system', 'cache');
  108. $schema['cache_media_xml']['description'] = 'Cache table for the the results of retreived XML documents for remote streams.';
  109. return $schema;
  110. }
  111. /**
  112. * Implements hook_field_schema().
  113. */
  114. function media_field_schema($field) {
  115. return array(
  116. 'columns' => array(
  117. 'fid' => array(
  118. 'type' => 'int',
  119. 'unsigned' => TRUE,
  120. 'not null' => FALSE,
  121. ),
  122. 'title' => array(
  123. 'type' => 'varchar',
  124. 'length' => 255,
  125. 'not null' => FALSE,
  126. ),
  127. 'data' => array(
  128. 'type' => 'text',
  129. 'not null' => FALSE,
  130. 'size' => 'big',
  131. 'serialize' => TRUE,
  132. //'description' => 'Used for storing additional information. Can be harnessed by widgets',
  133. ),
  134. ),
  135. 'indexes' => array(
  136. 'fid' => array('fid'),
  137. ),
  138. );
  139. }
  140. /**
  141. * Implements hook_install().
  142. */
  143. function media_install() {
  144. // @todo We may need to disable the media bundle & field in hook_disable.
  145. // Define the default type to be used if no other type is found. Give it a
  146. // high weight to ensure it runs last.
  147. $types['default'] = new stdClass();
  148. $types['default']->name = 'default';
  149. $types['default']->label = "Other";
  150. $types['default']->base = TRUE;
  151. $types['default']->weight = 1000;
  152. $types['default']->type_callback_args = array(
  153. 'match_type' => 'any',
  154. 'mimetypes' => array('/.*/'),
  155. );
  156. // Define the common media types: image, audio, and video.
  157. $types['image'] = new stdClass();
  158. $types['image']->name = 'image';
  159. $types['image']->label = "Image";
  160. $types['image']->base = TRUE;
  161. $types['image']->type_callback_args = array(
  162. 'match_type' => 'all',
  163. 'mimetypes' => array('/^image/'),
  164. 'extensions' => array('jpg', 'jpeg', 'gif', 'png', 'tiff'),
  165. 'streams' => array('public', 'private'),
  166. );
  167. $types['audio'] = new stdClass();
  168. $types['audio']->name = 'audio';
  169. $types['audio']->label = "Audio";
  170. $types['audio']->base = TRUE;
  171. $types['audio']->type_callback_args = array(
  172. 'match_type' => 'all',
  173. 'mimetypes' => array('/^audio/'),
  174. 'extensions' => array('mp3', 'ogg', 'wma'),
  175. 'streams' => array('public', 'private'),
  176. );
  177. $types['video'] = new stdClass();
  178. $types['video']->name = 'video';
  179. $types['video']->label = "Video";
  180. $types['video']->base = TRUE;
  181. $types['video']->type_callback_args = array(
  182. 'match_type' => 'all',
  183. 'mimetypes' => array('/^video/'),
  184. 'extensions' => array('mov', 'mp4', 'avi'),
  185. 'streams' => array('public', 'private'),
  186. );
  187. // Create the defined types.
  188. foreach ($types as $name => $type) {
  189. media_type_save($type);
  190. // @todo By default, we hide the file display in the 'small' view mode for
  191. // legacy reasons. Does it still make sense to do so? See
  192. // http://drupal.org/node/1051090.
  193. $bundle_settings = field_bundle_settings('file', $name);
  194. $bundle_settings['extra_fields']['display']['file']['media_small'] = array('weight' => 0, 'visible' => FALSE);
  195. field_bundle_settings('file', $name, $bundle_settings);
  196. }
  197. // Set permissions.
  198. $roles = user_roles();
  199. foreach ($roles as $rid => $role) {
  200. user_role_grant_permissions($rid, array('view media'));
  201. }
  202. // Updates the type field for the first MEDIA_UPDATE_RECORDS_ON_INSTALL files.
  203. $invalid_files = media_type_invalid_files_count();
  204. if ($invalid_files <= MEDIA_UPDATE_RECORDS_ON_INSTALL) {
  205. media_type_batch_update(FALSE, MEDIA_UPDATE_RECORDS_ON_INSTALL);
  206. }
  207. $invalid_files = media_type_invalid_files_count();
  208. if ($invalid_files > 0) {
  209. // Not all files could be converted. Display a persistant nag message on
  210. // every page for the administrator, urging them to finish the process.
  211. media_variable_set('show_file_type_rebuild_nag', TRUE);
  212. }
  213. }
  214. /**
  215. * Implements hook_uninstall().
  216. */
  217. function media_uninstall() {
  218. drupal_load('module', 'media');
  219. foreach (media_variable_default() as $name => $value) {
  220. media_variable_del($name);
  221. }
  222. }
  223. /**
  224. * Create the media_list_type table.
  225. */
  226. function media_update_7000() {
  227. $schema['media_list_type'] = array(
  228. 'description' => 'Stores the user preference for whether to list as table or images.',
  229. 'fields' => array(
  230. 'uid' => array(
  231. 'description' => 'The {user}.uid of the user.',
  232. 'type' => 'int',
  233. 'unsigned' => TRUE,
  234. 'not null' => TRUE,
  235. 'default' => 0,
  236. ),
  237. 'type' => array(
  238. 'description' => 'The type of display (table or images).',
  239. 'type' => 'varchar',
  240. 'length' => 32,
  241. 'not null' => TRUE,
  242. 'default' => '',
  243. ),
  244. ),
  245. 'primary key' => array('uid'),
  246. );
  247. db_create_table('media_list_type', $schema['media_list_type']);
  248. }
  249. /**
  250. * Create the cache_media_xml table.
  251. */
  252. function media_update_7001() {
  253. $schema['cache_media_xml'] = drupal_get_schema_unprocessed('system', 'cache');
  254. $schema['cache_media_xml']['description'] = 'Cache table for the the results of retreived XML documents for remote streams.';
  255. db_create_table('cache_media_xml', $schema['cache_media_xml']);
  256. }
  257. /**
  258. * Create the media_type table from the media_types variable.
  259. */
  260. function media_update_7002() {
  261. $schema['media_type'] = array(
  262. 'description' => 'Stores the settings for media types.',
  263. 'fields' => array(
  264. 'name' => array(
  265. 'description' => 'The machine name of the media type.',
  266. 'type' => 'varchar',
  267. 'length' => 255,
  268. 'not null' => TRUE,
  269. 'default' => '',
  270. ),
  271. 'label' => array(
  272. 'description' => 'The label of the media type.',
  273. 'type' => 'varchar',
  274. 'length' => 255,
  275. 'not null' => TRUE,
  276. 'default' => '',
  277. ),
  278. 'base' => array(
  279. 'description' => 'If this is a base type (i.e. cannot be deleted)',
  280. 'type' => 'int',
  281. 'not null' => TRUE,
  282. 'default' => 0,
  283. 'size' => 'tiny',
  284. ),
  285. 'weight' => array(
  286. 'description' => 'Weight of media type. Determines which one wins when claiming a piece of media (first wins)',
  287. 'type' => 'int',
  288. 'not null' => TRUE,
  289. 'default' => 0,
  290. 'size' => 'normal',
  291. ),
  292. 'type_callback' => array(
  293. 'description' => 'Callback to determine if provided media is of this type.',
  294. 'type' => 'varchar',
  295. 'length' => 255,
  296. 'not null' => FALSE,
  297. 'default' => '',
  298. ),
  299. 'type_callback_args' => array(
  300. 'type' => 'text',
  301. 'not null' => FALSE,
  302. 'size' => 'big',
  303. 'serialize' => TRUE,
  304. 'description' => 'A serialized array of name value pairs that will be passed to the callback function',
  305. ),
  306. ),
  307. 'primary key' => array('name'),
  308. );
  309. db_create_table('media_type', $scheme['media_type']);
  310. drupal_load('module', 'media');
  311. $old_types = variable_get('media_types');
  312. foreach ($old_types as $type) {
  313. // Was an error in the original creation
  314. if (isset($type->callbacks)) {
  315. unset($type->callbacks);
  316. }
  317. $type->name = $type->machine_name;
  318. unset($type->machine_name);
  319. media_type_save($type);
  320. }
  321. variable_del('media_types');
  322. }
  323. /**
  324. * We now prefix media namespaced variables with media__, so fix old variables.
  325. */
  326. function media_update_7003() {
  327. drupal_load('module', 'media');
  328. foreach (media_variable_default() as $variable => $value) {
  329. if (($test = variable_get('media_' . $variable, TRUE)) == variable_get('media_' . $variable, FALSE)) {
  330. media_variable_set($variable, $test);
  331. variable_del('media_' . $variable);
  332. }
  333. }
  334. }
  335. /**
  336. * Removed /media from the menu.
  337. */
  338. function media_update_7004() {
  339. // Do nothing. Running an update function will trigger a menu rebuild.
  340. }
  341. /**
  342. * Deprecated update function.
  343. */
  344. function media_update_7005() {
  345. }
  346. /**
  347. * Rename the file table to file_managed in case head2head was used.
  348. */
  349. function media_update_7006() {
  350. if (db_table_exists('file') && !db_table_exists('file_managed')) {
  351. db_rename_table('file', 'file_managed');
  352. }
  353. }
  354. /**
  355. * Changes the preview formatter for non-image types to the icon view.
  356. */
  357. function media_update_7007() {
  358. // @todo media_type_configure_formatters() is a deprecated function, so remove
  359. // this code entirely?
  360. drupal_load('module', 'media');
  361. drupal_load('module', 'field');
  362. foreach (media_type_get_types() as $type => $info) {
  363. if ($type != 'image') {
  364. media_type_configure_formatters($type, array('media_preview' => 'media_large_icon'));
  365. }
  366. }
  367. }
  368. /**
  369. * Give all users view media perm by default
  370. */
  371. function media_update_7008() {
  372. $roles = user_roles();
  373. foreach ($roles as $rid => $role) {
  374. user_role_grant_permissions($rid, array('view media'));
  375. }
  376. }
  377. /**
  378. * Changes the preview formatter for video types to a square thumbnail, like for images.
  379. */
  380. function media_update_7009() {
  381. // @todo media_type_configure_formatters() is a deprecated function, so remove
  382. // this code entirely?
  383. drupal_load('module', 'media');
  384. drupal_load('module', 'field');
  385. media_type_configure_formatters('video', array('media_preview' => 'styles_file_square_thumbnail'));
  386. }
  387. /**
  388. * Changes the large formatter for video types to the large file style.
  389. */
  390. function media_update_7010() {
  391. // @todo media_type_configure_formatters() is a deprecated function, so remove
  392. // this code entirely?
  393. // This formatter association was added to media_enable() at one point, but
  394. // without a corresponding update function, so here's that update function.
  395. drupal_load('module', 'media');
  396. drupal_load('module', 'field');
  397. media_type_configure_formatters('video', array('media_large' => 'styles_file_large'));
  398. }
  399. /**
  400. * Empty update function.
  401. */
  402. function media_update_7011() {
  403. }
  404. /**
  405. * Create the media_filter_usage table.
  406. */
  407. function media_update_7012() {
  408. $schema['media_filter_usage'] = array(
  409. 'description' => 'Stores fids that have been included in the media tag in formatted textareas.',
  410. 'fields' => array(
  411. 'fid' => array(
  412. 'description' => 'The media {file_managed}.fid.',
  413. 'type' => 'int',
  414. 'unsigned' => TRUE,
  415. 'not null' => TRUE,
  416. 'default' => 0,
  417. ),
  418. 'timestamp' => array(
  419. 'description' => 'The timestamp the fid was last recorded by media_filter()',
  420. 'type' => 'int',
  421. 'not null' => TRUE,
  422. 'default' => 0,
  423. ),
  424. ),
  425. 'foreign keys' => array(
  426. 'file_managed' => array(
  427. 'table' => 'file_managed',
  428. 'columns' => array('fid' => 'fid'),
  429. ),
  430. ),
  431. 'primary key' => array('fid'),
  432. 'indexes' => array(
  433. 'timestamp' => array('timestamp'),
  434. ),
  435. );
  436. db_create_table('media_filter_usage', $schema['media_filter_usage']);
  437. }
  438. /**
  439. * Work around a core bug where text format cacheability is not updated.
  440. *
  441. * @see http://drupal.org/node/993230
  442. */
  443. function media_update_7013() {
  444. $formats = filter_formats();
  445. foreach ($formats as $format) {
  446. $format->filters = filter_list_format($format->format);
  447. // filter_format_save() expects filters to be an array, however
  448. // filter_list_format() gives us objects.
  449. foreach ($format->filters as $key => $value) {
  450. $format->filters[$key] = (array) $value;
  451. }
  452. filter_format_save($format);
  453. }
  454. }
  455. /**
  456. * Rename the media__dialog_get_theme_name variable to media__dialog_theme.
  457. */
  458. function media_update_7014() {
  459. if ($old_value = variable_get('media__dialog_get_theme_name')) {
  460. variable_del('media__dialog_get_theme_name');
  461. variable_set('media__dialog_theme', $old_value);
  462. }
  463. }
  464. /**
  465. * Empty update function to trigger a registry rebuild.
  466. */
  467. function media_update_7015() {
  468. }
  469. /**
  470. * Convert Media entities to File entities.
  471. */
  472. function media_update_7016() {
  473. // Allow File Entity module to take over the {file_managed}.type field. It
  474. // will create new indexes as it needs to, but it doesn't know about old ones,
  475. // so delete them.
  476. if (db_index_exists('file_managed', 'file_type')) {
  477. db_drop_index('file_managed', 'file_type');
  478. }
  479. module_enable(array('file_entity'));
  480. // Move all field instances from Media entity to File entity.
  481. $instances = field_read_instances(array('entity_type' => 'media'), array('include_inactive' => TRUE, 'include_deleted' => TRUE));
  482. foreach ($instances as $instance) {
  483. // Skip the old self-referencing file field. It will be deleted later in
  484. // this function.
  485. if ($instance['field_name'] === 'file') {
  486. continue;
  487. }
  488. // @todo Convert this to use _update_7000_field_read_fields()
  489. $fields = field_read_fields(array('id' => $instance['field_id']), array('include_inactive' => TRUE, 'include_deleted' => TRUE));
  490. $field = $fields[$instance['field_id']];
  491. // There is no API for updating the entity_type foreign key within field
  492. // data storage. We can do a direct db_update() for when the default SQL
  493. // storage back-end is being used, but must skip updating fields that use a
  494. // different storage type.
  495. // @todo What else should be added here (e.g., logging and/or a message to
  496. // the administrator)?
  497. if ($field['storage']['type'] !== 'field_sql_storage' || !module_exists('field_sql_storage') || !$field['storage']['active']) {
  498. $messages[] = t('Cannot update field %id (%field_name) because it does not use the field_sql_storage storage type.', array(
  499. '%id' => $field['id'],
  500. '%field_name' => $field['field_name'],
  501. ));
  502. continue;
  503. }
  504. // Update the data tables.
  505. $table_name = _field_sql_storage_tablename($field);
  506. $revision_name = _field_sql_storage_revision_tablename($field);
  507. db_update($table_name)
  508. ->fields(array('entity_type' => 'file'))
  509. ->condition('entity_type', 'media')
  510. ->condition('bundle', $instance['bundle'])
  511. ->execute();
  512. db_update($revision_name)
  513. ->fields(array('entity_type' => 'file'))
  514. ->condition('entity_type', 'media')
  515. ->condition('bundle', $instance['bundle'])
  516. ->execute();
  517. // Once all the data has been updated, update the {field_config_instance}
  518. // record.
  519. db_update('field_config_instance')
  520. ->fields(array('entity_type' => 'file'))
  521. ->condition('id', $instance['id'])
  522. ->execute();
  523. }
  524. // Update the field_bundle_settings configuration variable: move media bundle
  525. // settings to file bundles, and move settings of the old self-referencing
  526. // file field to the new file pseudo-field.
  527. $settings = variable_get('field_bundle_settings', array());
  528. if (!isset($settings['file'])) {
  529. $settings['file'] = array();
  530. }
  531. if (isset($settings['media'])) {
  532. $settings['file'] = array_merge($settings['file'], $settings['media']);
  533. unset($settings['media']);
  534. }
  535. foreach ($instances as $instance) {
  536. if ($instance['field_name'] === 'file' && !$instance['deleted']) {
  537. if (isset($instance['widget']['weight'])) {
  538. $settings['file'][$instance['bundle']]['extra_fields']['form']['file']['weight'] = $instance['widget']['weight'];
  539. }
  540. if (isset($instance['display'])) {
  541. foreach ($instance['display'] as $view_mode => $display) {
  542. if (isset($display['weight'])) {
  543. $settings['file'][$instance['bundle']]['extra_fields']['display']['file'][$view_mode]['weight'] = $display['weight'];
  544. }
  545. if (isset($display['type'])) {
  546. $settings['file'][$instance['bundle']]['extra_fields']['display']['file'][$view_mode]['visible'] = ($display['type'] != 'hidden');
  547. }
  548. }
  549. }
  550. }
  551. }
  552. variable_set('field_bundle_settings', $settings);
  553. // Copy field formatter settings of old self-referencing file field to file
  554. // pseudo-field formatter settings.
  555. $file_displays = variable_get('file_displays', array());
  556. foreach ($instances as $instance) {
  557. if ($instance['field_name'] === 'file' && !$instance['deleted']) {
  558. if (isset($instance['display'])) {
  559. foreach ($instance['display'] as $view_mode => $display) {
  560. if (isset($display['type']) && $display['type'] != 'hidden') {
  561. $file_formatter = 'file_field_' . $display['type'];
  562. $file_displays[$instance['bundle']][$view_mode][$file_formatter]['status'] = TRUE;
  563. if (isset($display['settings'])) {
  564. $file_displays[$instance['bundle']][$view_mode][$file_formatter]['settings'] = $display['settings'];
  565. }
  566. }
  567. }
  568. }
  569. }
  570. }
  571. variable_set('file_displays', $file_displays);
  572. // Delete the old self-referencing file field instances. If all instances are
  573. // deleted, field_delete_instance() will delete the field too.
  574. foreach ($instances as $instance) {
  575. if ($instance['field_name'] === 'file' && !$instance['deleted']) {
  576. field_delete_instance($instance);
  577. }
  578. }
  579. field_cache_clear();
  580. }
  581. /**
  582. * Move file display configurations from the 'file_displays' variable to the
  583. * {file_display} table.
  584. */
  585. function media_update_7017() {
  586. // If the {file_display} table doesn't exist, then the File Entity module's
  587. // update functions will automatically take care of migrating the
  588. // configurations. However, if file_entity_update_7001() has already run
  589. // prior to media_update_7016(), run it again in order to capture those
  590. // configurations too.
  591. if (db_table_exists('file_display')) {
  592. file_entity_update_7001();
  593. }
  594. }
  595. /**
  596. * Empty update function to trigger a menu rebuild.
  597. */
  598. function media_update_7018() {
  599. }
  600. /**
  601. * Update old per-view-mode media field formatters to the generic media formatter with a setting.
  602. */
  603. function media_update_7019() {
  604. $instances = array();
  605. $fields = field_read_fields(array('type' => 'media'), array('include_inactive' => TRUE));
  606. foreach ($fields as $field) {
  607. $instances = array_merge($instances, field_read_instances(array('field_id' => $field['id']), array('include_inactive' => TRUE)));
  608. }
  609. foreach ($instances as $instance) {
  610. $update_instance = FALSE;
  611. foreach ($instance['display'] as $view_mode => $display) {
  612. if (in_array($display['type'], array('media_link', 'media_preview', 'media_small', 'media_large', 'media_original'))) {
  613. $update_instance = TRUE;
  614. $instance['display'][$view_mode]['type'] = 'media';
  615. $instance['display'][$view_mode]['settings'] = array('file_view_mode' => $display['type']);
  616. }
  617. }
  618. if ($update_instance) {
  619. field_update_instance($instance);
  620. }
  621. }
  622. }
  623. /**
  624. * Delete the wysiwyg_allowed_types variable if it is the same as default.
  625. */
  626. function media_update_7020() {
  627. if (variable_get('media__wysiwyg_allowed_types') == array('image', 'video')) {
  628. variable_del('media__wysiwyg_allowed_types');
  629. }
  630. }