Problem
media_wysiwyg_view_mode sub module enables us to restrict view mode options end-user can choose in the media dialog. We can select which type of file we want to restrict view modes and which view modes should be visible by end-users on page `admin/config/media/wysiwyg-view-mode`.
For example I want user can only select 'default', 'preview' view modes for image and tick those options on the page above. However when I go to the WYSIWYG, I cannot see these two options and see view mode 'wysiwyg' instead. I have dig into code and find it is implemented in a reverse logic.
function media_wysiwyg_view_mode_media_wysiwyg_wysiwyg_allowed_view_modes_alter(&$view_modes, &$file) {
if (variable_get("media_wysiwyg_view_mode_{$file->type}_wysiwyg_restricted_view_modes_status", FALSE) == TRUE) {
$restricted_view_modes = variable_get("media_wysiwyg_view_mode_{$file->type}_wysiwyg_restricted_view_modes", array());
foreach ($restricted_view_modes as $restricted_view_mode) {
if (array_key_exists($restricted_view_mode, $view_modes)) {
unset($view_modes[$restricted_view_mode]);
}
}
}
}
From the code I have found all selected view modes have been removed from view mode options.
Comments
Comment #1
eric.chenchao commentedPatch is attached:)
Comment #3
eric.chenchao commentedComment #5
eric.chenchao commentedI just realized that the original code does the work to allow user disable particular view modes. But I guess select allowed view mode instead of restrict (disable) view mode is more straight forward:)
Comment #6
eric.chenchao commentedComment #7
dave reidI've gone through and revised the UI to make it more clear how this logic works. This will need a large update since #2158177: Confusing UI for WYSIWYG view modes was committed.
Comment #8
dave reidBetter title now with the direction.
Comment #9
eelkeblokEven though the UI is a huge improvement with #2158177: Confusing UI for WYSIWYG view modes, I still fell in "the trap". Luckily, now the wording in the UI is there to sort of quickly find your mistake. It's still unintuitive, though, so +1 for this change.
Comment #10
rooby commentedI don't think this is still relevant now that these settings have been split out to the actual field display admin pages.
Comment #11
joseph.olstadBased on comment above by @rooby