function media_wysiwyg_file_displays_alter in D7 Media 7.4
Same name and namespace in other branches
- 7.2 modules/media_wysiwyg/media_wysiwyg.module \media_wysiwyg_file_displays_alter()
- 7.3 modules/media_wysiwyg/media_wysiwyg.module \media_wysiwyg_file_displays_alter()
Implements hook_file_displays_alter().
File
- modules/
media_wysiwyg/ media_wysiwyg.module, line 636 - Primarily Drupal hooks.
Code
function media_wysiwyg_file_displays_alter(&$displays, $file, $view_mode) {
// Override the fields of the file when requested by the WYSIWYG.
if (isset($file->override)) {
$instance = field_info_instances('file', $file->type);
foreach ($file->override as $field_name => $value) {
if (!isset($instance[$field_name]['settings']) || !isset($instance[$field_name]['settings']['wysiwyg_override']) || $instance[$field_name]['settings']['wysiwyg_override']) {
$file->{$field_name} = $value;
}
}
}
// For integration/support of the picture module https://www.drupal.org/project/picture.
// Disable Picture display in WYSIWYG mode. Normal <img> will be rendered
// instead. CKEditor and Media WYSIWYG modules with render with common <img>
// while frontend will render full <picture> output as usual.
if (module_exists('picture')) {
if (!empty($file->override['wysiwyg']) && !empty($displays['file_field_picture']['status'])) {
$displays['file_field_picture']['status'] = 0;
}
}
}