function _thunder_media_media_field_widget_form_alter_helper in Thunder 8.2
Same name and namespace in other branches
- 8.5 modules/thunder_media/thunder_media.module \_thunder_media_media_field_widget_form_alter_helper()
- 8.3 modules/thunder_media/thunder_media.module \_thunder_media_media_field_widget_form_alter_helper()
- 8.4 modules/thunder_media/thunder_media.module \_thunder_media_media_field_widget_form_alter_helper()
- 6.2.x modules/thunder_media/thunder_media.module \_thunder_media_media_field_widget_form_alter_helper()
- 6.0.x modules/thunder_media/thunder_media.module \_thunder_media_media_field_widget_form_alter_helper()
- 6.1.x modules/thunder_media/thunder_media.module \_thunder_media_media_field_widget_form_alter_helper()
Helper function for form alter hooks to alter the media field widget.
Parameters
array $widget: The media form field widget.
string $media_type: The type of media.
1 call to _thunder_media_media_field_widget_form_alter_helper()
- thunder_media_field_widget_entity_browser_entity_reference_form_alter in modules/
thunder_media/ thunder_media.module - Implements hook_field_widget_WIDGET_ID_form_alter().
File
- modules/
thunder_media/ thunder_media.module, line 183 - Contains media related functions.
Code
function _thunder_media_media_field_widget_form_alter_helper(array &$widget, $media_type) {
// Process the media field widget.
$widget['#attributes']['class'][] = 'media-form__items-widget';
if (isset($widget['current']['items'])) {
if (count($widget['current']['items']) == 1) {
$widget['current']['#attributes']['class'][] = 'entities-list--single-item';
}
foreach ($widget['current']['items'] as &$media_item) {
$media_item['#attributes']['class'][] = 'media-form__item-widget';
$media_item['#attributes']['class'][] = 'media-form__item-widget--' . $media_type;
if (isset($media_item['remove_button'])) {
$media_item['remove_button']['#attributes']['class'][] = 'media-form__item-widget__action';
$media_item['remove_button']['#attributes']['class'][] = 'media-form__item-widget__action--remove';
// Add our own "button action type" key to be able to use a distinct
// template via suggestions in the theme.
$media_item['remove_button']['#button_action_type'] = 'media_remove';
}
if (isset($media_item['edit_button'])) {
$media_item['edit_button']['#attributes']['class'][] = 'media-form__item-widget__action';
$media_item['edit_button']['#attributes']['class'][] = 'media-form__item-widget__action--edit';
// Add our own "button action type" key to be able to use a distinct
// template via suggestions in the theme.
$media_item['edit_button']['#button_action_type'] = 'media_edit';
}
}
}
}