Support more asset_search_key values for Asset plugin

Created on 28 May 2025, 8 days ago

Problem/Motivation

In ✨ Allow for extending supported asset types Active new Asset plugins were added to allow a more extensible and customizable integration with the DAM.

The two important plugin propeties are:

  /**
   * The search key passed to DAM.
   *
   * @var string
   */
  public $asset_search_key;

  /**
   * The search value passed to DAM.
   *
   * @var string
   */
  public $asset_search_value;

This looks promising, but at the moment there really are only two values of asset_search_key that are supported. They are ft and ff. The acquia_dam_asset_type Views argument and the acquia_dam_asset_import queue appear to support any asset search key that is valid with Widen search. However, the MediaTypeResolver has ff and ft hardcoded in a mapping that can't be altered in any way.

$mapping = [
      'ft' => 'format_type',
      'ff' => 'format',
 ];

So that's where the trouble comes in.

Steps to reproduce

Use an alter hook to add a new plugin definition that uses some other search key. In this case, we use a metadata property with the key assetType.

/**
* Implements hook_acquia_dam_media_source_info_alter().
*/
function my_module_acquia_dam_media_source_alter(&$definitions) {
if (isset($definitions['image'])) {
$definitions['icon'] = $definitions['image'];
$definitions['icon']['id'] = 'icon';
$definitions['icon']['label'] = 'Icon';
$definitions['icon']['asset_search_key'] = 'assetType';
$definitions['icon']['asset_search_value'] = 'Icon';
}
}

Thus the icon Asset plugin is just like the image plugin but it searches using the assetType metadata instead of the format_type file property.

Proposed resolution

I would like the MediaTypeResolver to try its best to use search keys that are not in the hard coded mapping. The resolver would look for the key in both the asset's file_properties and its metadata.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

1.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States danflanagan8 St. Louis, US

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024