-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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