In /admin/config/media/wysiwyg-view-mode, when i check "Restrict allowed view modes for Image" and WYSIWYG in "Restrict view modes", Wysiwyg option disappear from select list on wysiwyg media window.

If i check all others, only wysiwyg appear, but file isn't rendered in entity display because it isn't allowed (because it isn't checked).

Next patch will fix this

Comments

goz’s picture

Status: Active » Needs review
StatusFileSize
new1.48 KB

Here is the patch

This patch is part of the #1day1patch initiative.

reubenavery’s picture

+1 for this. Thanks, GoZ.

mkhamash’s picture

Component: WYSIWYG integration » Code
Issue summary: View changes
StatusFileSize
new1.48 KB

This patch does solve the issue of allowed view mode, I have made a new patch file against the latest dev bransh "7.x-2.0-alpha3+82-dev"

Status: Needs review » Needs work
mkhamash’s picture

letrotteur’s picture

Fixed the issue for me. Thanks.

rooby’s picture

I can't reproduce this bug.
If I select all except the "WYSIWYG" view mode it works as expected.

The problem with this patch is that it reverses the way that the setting currently works which means it will break sites set up the current way (which is why the automated tests break for your patch above).

If i check all others, only wysiwyg appear, but file isn't rendered in entity display because it isn't allowed (because it isn't checked).

If this is your problem then the patch should focus on fixing this so that the entity is displayed properly instead of reversing the settings (even though I agree that the current setting is a bit confusing and it would be better the way your patch makes it).
Alternatively you would need to include extra changes in your patch to change the name of the variable and the user interface text to be allowed view modes and handle an upgrade path for existing settings.

As a side note a simpler way to achieve the logic in this patch would be to do something like this:

<?php
  // Get a list of the allowed view modes.
  $allowed_view_modes = array_filter(variable_get("media_wysiwyg_view_mode_{$file->type}_wysiwyg_restricted_view_modes", array()));
  // Restrict view modes to only those that are in the allowed view modes.
  $view_modes = array_intersect_key($view_modes, $allowed_view_modes);
?>
dave reid’s picture

Component: Code » Media WYSIWYG View Mode
Status: Needs work » Closed (duplicate)
Related issues: +#2479947: Switch to using an 'allowed view modes' logic instead of restricting view modes