function media_update_7019 in D7 Media 7.3
Same name and namespace in other branches
- 7.4 media.install \media_update_7019()
- 7 media.install \media_update_7019()
- 7.2 media.install \media_update_7019()
Update old view mode formaters.
Update old per-view-mode media field formatters to the generic media formatter with a setting.
File
- ./
media.install, line 513 - Install, update and uninstall functions for the Media module.
Code
function media_update_7019() {
$instances = array();
$fields = field_read_fields(array(
'type' => 'media',
), array(
'include_inactive' => TRUE,
));
foreach ($fields as $field) {
$instances = array_merge($instances, field_read_instances(array(
'field_id' => $field['id'],
), array(
'include_inactive' => TRUE,
)));
}
foreach ($instances as $instance) {
$update_instance = FALSE;
foreach ($instance['display'] as $view_mode => $display) {
if (in_array($display['type'], array(
'media_link',
'media_preview',
'media_small',
'media_large',
'media_original',
))) {
$update_instance = TRUE;
$instance['display'][$view_mode]['type'] = 'media';
$instance['display'][$view_mode]['settings'] = array(
'file_view_mode' => $display['type'],
);
}
}
if ($update_instance) {
field_update_instance($instance);
}
}
}