- Issue created by @danflanagan8
- Merge request !159Support unmapped asset_search_key value in asset file_properties or metadata β (Open) created by danflanagan8
- πΊπΈUnited States danflanagan8 St. Louis, US
I put in an MR. Setting to NR.
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.
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.
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.
Active
1.1
Code
I put in an MR. Setting to NR.