Add filter option for bynder compact view

Created on 7 July 2025, 6 days ago
Updated 8 July 2025, 6 days ago

Problem/Motivation

The bynder compact views allows to add additional filters, to prefilter the assets on the search view.
It's currently possible to alter the entity browser form widget, but not to adjust the filters itself on the bynder view e.g. with:

/**
 * Hook for hook_form_entity_browser_form_alter.
 */
  #[Hook('form_entity_browser_form_alter')]
  public function formEntityBrowserFormAlter(array &$form, FormStateInterface $form_state, $form_id): void {
    if (strpos($form_id, 'entity_browser_') === 0 && !empty($form['widget']['#attached']['drupalSettings']['bynder'])) {
      // add some custom filters here...
      $form['widget']['#attached']['drupalSettings']['bynder']['additionalFilters'] = [
        'assetFilter' => [
          'predefinedMetapropertiesOptions' => [
            'Asset_usage' => [
              'Free_for_use' => '262C882E-4378-4E5F-AC17B0F0EFF946F1',
            ],
          ],
          'showToolbar' => TRUE,
          'predefinedAssetType' => array_map('strtoupper', $form['widget']['#attached']['drupalSettings']['bynder']['types']),
        ],
      ];
    }
  }

Steps to reproduce

issue is that the bynder.search_view.js is currently fixed related to the filters properties - no change to add some custom filter.

Proposed resolution

idea would be to simply merge the bynder compact view to allow adding custom filters

// Get custom config if available
            const customConfig = drupalSettings.bynder?.additionalFilters || {};

            // Merge configurations
            const finalConfig = {
              ...baseConfig,
              ...customConfig
            }
            BynderCompactView.open(finalConfig);
Feature request
Status

Active

Version

4.3

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024