function _media_update_7204_update_views_display_options in D7 Media 7.4
Same name and namespace in other branches
- 7.2 media.install \_media_update_7204_update_views_display_options()
- 7.3 media.install \_media_update_7204_update_views_display_options()
Utility function for update 7204. Updates display options within Views.
1 call to _media_update_7204_update_views_display_options()
- media_update_7204 in ./
media.install - Update old Media view modes to the new File Entity ones.
File
- ./
media.install, line 1002 - Install, update and uninstall functions for the Media module.
Code
function _media_update_7204_update_views_display_options(&$display_options, $view_mode_updates) {
$updated = FALSE;
// Update fields that use a formatter with a file_view_mode formatter setting.
if (!empty($display_options['fields'])) {
foreach ($display_options['fields'] as $field_name => $field_display) {
if (isset($field_display['settings']['file_view_mode']) && isset($view_mode_updates[$field_display['settings']['file_view_mode']])) {
$display_options['fields'][$field_name]['settings']['file_view_mode'] = $view_mode_updates[$field_display['settings']['file_view_mode']];
$updated = TRUE;
}
}
}
// Update Views that display files directly using a row plugin with a view
// mode setting.
if (isset($display_options['row_plugin']) && $display_options['row_plugin'] === 'file' && isset($display_options['row_options']['view_mode']) && isset($view_mode_updates[$display_options['row_options']['view_mode']])) {
$display_options['row_options']['view_mode'] = $view_mode_updates[$display_options['row_options']['view_mode']];
$updated = TRUE;
}
return $updated;
}