How could i limit file styles, user can insert with WYSIWG editor to, for example, "preview" and "large"?
I need it for input format and insert button both.

CommentFileSizeAuthor
#5 drupal-1413300-example-code.php_.gz1.11 KBrwohleb

Comments

pomliane’s picture

Title: Limit file styles avaliable to user » Limit file styles available to user
Version: 7.x-2.0-unstable3 » 7.x-2.x-dev
Component: Media Browser » WYSIWYG integration
Category: bug » feature
gmclelland’s picture

johnpitcairn’s picture

It's certainly possible to implement hook_form_media_format_form_alter() in a module, and manipulate everything there.

But hopefully a better (UI) solution for the general media-format vs image-styles confusion will emerge. The situation at present is convoluted and confusing to say the least.

devin carlson’s picture

Status: Active » Closed (fixed)

As John Pitcairn mentioned in #3, you can currently modify the file styles presented to users by implementing hook_form_media_format_form_alter() in a custom module.

For example, to remove the "large" file style from being selectable, add the following to the module "example":

function example_media_wysiwyg_allowed_view_modes_alter(&$view_modes, &$file) {
  unset('media_large');
}

Work on creating an easier method of configuring the available file styles in occurring in #1632502: Limit WYSIWYG View Modes to Enabled Modes and #1283844: [meta] Improve WYSIWYG integration.

rwohleb’s picture

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

For anyone interested, I'm attaching some example code that will modify the browser settings form allowing you to select which file view/display modes to allow. I'm not attaching a patch since I don't think this is really the way we want to take it, but it's a decent stop-gap measure.