Skip to content

Instantly share code, notes, and snippets.

@lslinnet
Created May 10, 2013 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lslinnet/1ade60dc12907c42ab09 to your computer and use it in GitHub Desktop.
Save lslinnet/1ade60dc12907c42ab09 to your computer and use it in GitHub Desktop.
An example of how to modify what image presets you are allowed to insert through the wysiwyg editor.
<?php
/**
* @file
* Code for the mycustom media feature.
*/
include_once 'mycustom_media.features.inc';
/**
* Implements hook_media_wysiwyg_allowed_view_modes_alter().
*
* Remove image styles when inserting images using wysiwyg.
*/
function mycustom_media_wysiwyg_allowed_view_modes_alter(&$view_modes, &$file) {
$allowed_formats = array(
'mycustom_media_custom_special_110x110',
'media_original',
'another_image_style',
);
foreach ($view_modes as $key => $view_mode) {
if (!in_array($key, $allowed_formats)) {
unset($view_modes[$key]);
}
}
}
/**
* Implements hook_media_browser_plugins_alter().
*
* Unset unrequired media browser plugins in wysiwyg editor
*/
function mycustom_media_media_browser_plugins_alter(&$plugins) {
$disabled_plugins = array(
'media_internet',
'media_default--media_browser_1',
'library',
'ns_media_browser--media_browser_1',
'media_default--media_browser_my_files',
'mycustom_media_browser--media_browser_my_files',
);
foreach ($disabled_plugins as $plugin) {
unset($plugins[$plugin]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment