4 * Contains \Drupal\bootstrap\Plugin\Preprocess\ImageWidget.
7 namespace Drupal\bootstrap\Plugin\Preprocess;
9 use Drupal\bootstrap\Annotation\BootstrapPreprocess;
10 use Drupal\bootstrap\Utility\Element;
11 use Drupal\bootstrap\Utility\Variables;
14 * Pre-processes variables for the "image_widget" theme hook.
16 * @ingroup plugins_preprocess
18 * @see image-widget.html.twig
20 * @BootstrapPreprocess("image_widget",
21 * replace = "template_preprocess_image_widget"
24 class ImageWidget extends PreprocessBase implements PreprocessInterface {
29 public function preprocessElement(Element $element, Variables $variables) {
30 $variables->addClass(['image-widget', 'js-form-managed-file', 'form-managed-file', 'clearfix']);
32 $data = &$variables->offsetGet('data', []);
33 foreach ($element->children() as $key => $child) {
34 $data[$key] = $child->getArray();