function media_wysiwyg_token_upgrade_40 in D7 Media 7.4
Upgrade a single media token from 3.0 to 4.0.
Parameters
array $settings: Media instance settings, aka tag_info.
1 call to media_wysiwyg_token_upgrade_40()
- media_wysiwyg_upgrade_token in modules/
media_wysiwyg/ includes/ media_wysiwyg.upgrade.inc - Upgrade a single media token to latest version.
File
- modules/
media_wysiwyg/ includes/ media_wysiwyg.upgrade.inc, line 273 - Code related to media token upgrades.
Code
function media_wysiwyg_token_upgrade_40(array &$settings) {
// The old 'fields' subarray is now flattened and main structure of our token.
// Just move every values to settings root, and rename 'format' to
// 'view_mode'.
if (is_array($settings['fields'])) {
// First, remove properties that leaked over to the fields sub-structure.
// @see issue #2946265.
foreach (media_wysiwyg_allowed_attributes() as $attribute) {
unset($settings['fields'][$attribute]);
}
foreach ($settings['fields'] as $property => $value) {
$settings[$property] = $value;
}
// Although 'view_mode' should be set, we double check and use the one
// provided from (the old) media_wysiwyg_format_form().
if (!empty($settings['fields']['format'])) {
$settings['view_mode'] = $settings['format'];
}
}
// Validate and rebuild. Exceptions are cought further up the call stack.
media_wysiwyg_validate_instance_settings($settings);
$settings = media_wysiwyg_rebuild_instance_settings($settings);
}