What Changed
Acquia DAM now provides a plugin-based architecture for asset media sources, allowing developers to create custom asset types beyond the default types provided by the module. Previously, asset types were hard-coded and classes like Asset, AssetDeriver, and MediaTypeResolver were marked as final, preventing extensibility.
Note: Some of this work is still ongoing; there are areas of legacy code where types or plugins are referenced directly. The eventual plan is to move all type specific logic into plugins. Therefore, any bugs or feature requests that continues this anti-pattern will not be committed, rather the issue should involve moving the affected code into the relevant plugin.
Problem Solved
Before: Asset types were hard-coded to match Widen's asset definitions:
- Audio
- Documents
- Generic
- Image
- Spinset
- Video
This prevented organizations from creating custom asset type segmentation based on their specific metadata needs (e.g., separating "Icons" from "Images" or "Photographs" from "Illustrations").
After: New plugin system allows custom asset types through the @AssetMediaSource annotation.
How to Create Custom Asset Types
Create a new plugin class extending MediaSourceTypeBase:
<?php
namespace Drupal\my_module\Plugin\media\acquia_dam;
use Drupal\acquia_dam\Plugin\media\acquia_dam\MediaSourceTypeBase;
/**
* Provides a custom Icon asset type.
*
* @AssetMediaSource(
* id = "icon",
* label = @Translation("Acquia DAM: Icon"),
* default_thumbnail_filename = "icon.png",
* asset_search_key = "metadata_field",
* asset_search_value = "icon",
* )
*/
class Icon extends MediaSourceTypeBase {
/**
* {@inheritdoc}
*/
public function getActiveFieldName() {
// Override to customize which field is active based on your workflow
return parent::getActiveFieldName();
}
/**
* {@inheritdoc}
*/
public function getFormatter() {
// Override to customize formatter settings for this asset type
return parent::getFormatter();
}
}
Plugin Annotation Parameters
id- Unique identifier for the asset typelabel- Human-readable label displayed in the UIdefault_thumbnail_filename- Default thumbnail imageasset_search_key- Widen API field to search (e.g.,ftfor file type, or custom metadata field)asset_search_value- Value to match for this asset type
Key Methods in MediaSourceTypeBase
getActiveFieldName()
Returns the active field based on whether "Download and sync assets" is enabled. Override this to implement custom field selection logic.
getFormatter()
Returns formatter settings from the asset field formatter configuration. Override to customize how assets are displayed.
$embedCodeAssetField
Protected property for the default embed code field, required even for Download/Sync workflow.
Use Case Example
Scenario: Your organization stores both "Photographs" and "Icons" in Acquia DAM as Images, but uses custom metadata to distinguish them.
Solution:
- Create two custom plugins: Photograph and Icon
- Use asset_search_key to reference your custom metadata field
- Set asset_search_value to match the metadata value
- Assets are automatically routed to the correct Drupal media type based on metadata
// Shockwave Flash plugin
@AssetMediaSource(
id = "shockwave_flash",
label = @Translation("Acquia DAM: Shockwave Flash"),
asset_search_key = "ft",
asset_search_value = "shockwave",
)
// Ebook plugin
@AssetMediaSource(
id = "ebook",
label = @Translation("Acquia DAM: Ebook"),
asset_search_key = "ft",
asset_search_value = "ebook",
)
Benefits
✅ Extensible architecture - Add custom asset types without modifying core module code
✅ Metadata-based routing - Segment assets based on custom Widen metadata
✅ Multiple media types per Widen type - Create specialized Drupal media types for the same Widen asset format
✅ Override-friendly - Extend MediaSourceTypeBase and override methods as needed
✅ Backward compatible - All default asset types continue to work unchanged
Breaking Changes
None. This is a new feature that adds extensibility without changing existing functionality.