Thx, can confirm this patch fixed it.
Can confirm this patch works
Mapping is way easier, thanks for great work!
Can confirm this patch applies and works for me.
There is a small difference between version 4.x-dev and 4.2.1, should we perhaps open a separate issue for this? In the meantime, I’ve already added a patch for version 4.2.1
Can confirm this works, Thx!
Can confirm patch in #10 fixed it for me, running D10.3
The mapping logic and list of properties that can be mapped is defined in the source plugin Bynder.php.
I created a custom media source plugin which extends the Bynder one.
In the hook_media_source_info_alter I have set my custom source plugin for the Bynder one.
In hook_bynder_media_update_alter you can fix the field mapping.
Code can probably be better but this worked for me.
<?php
use Drupal\custom_module\Plugin\media\Source\CustomBynder;
use Drupal\media\MediaInterface;
/**
* Implements hook_media_source_info_alter().
*/
function custom_module_media_source_info_alter(array &$sources) {
$sources['bynder']['class'] = CustomBynder::class;
}
/**
* Implements hook_bynder_media_update_alter().
*
* Save mapped metadata to the media entity.
*/
function custom_module_bynder_media_update_alter(MediaInterface $media, array $item, &$has_changed) {
/** @var \Drupal\media\MediaTypeInterface $bundle */
$bundle = $media->get($media->getEntityType()->getKey('bundle'))->entity;
$mapping = [
'field_property_usage_rights' => 'property_Usage_Rights',
'field_property_category' => 'property_Category',
'field_bynder_type' => 'property_Asset_Type',
'field_property_asset_sub' => 'property_Asset_Sub',
];
foreach ($bundle->getFieldMap() as $metadata_attribute_name => $entity_field_name) {
if (array_key_exists($metadata_attribute_name, $mapping)) {
$metadata_attribute_name = $mapping[$entity_field_name];
}
if (array_key_exists($metadata_attribute_name, $item) && $media->hasField($entity_field_name)) {
$has_changed = TRUE;
$media->set($entity_field_name, $item[$metadata_attribute_name]);
}
}
$media->updateQueuedThumbnail();
}
<?php
declare(strict_types=1);
namespace Drupal\custom_module\Plugin\media\Source;
use Drupal\bynder\Plugin\media\Source\Bynder;
/**
* Plugin overwrite for 'bynder'
*
* Extends the plugin to provide the extra properties.
*
*/
final class CustomBynder extends Bynder {
/**
* {@inheritdoc}
*/
public function getMetadataAttributes(): array {
$attributes = parent::getMetadataAttributes();
return array_merge($attributes, [
'property_usage_rights' => $this->t('Property Usage Rights'),
'property_category' => $this->t('Property Category'),
'property_asset_type' => $this->t('Property Asset Type'),
'property_asset_sub' => $this->t('Property Asset Sub'),
]);
}
/**
* {@inheritdoc}
*/
public function getRemoteMetadataProperties(): array {
$properties = parent::getRemoteMetadataProperties();
return array_merge($properties, [
'property_Usage_Rights',
'property_Category',
'property_Asset_Type',
'property_Asset_Sub',
]);
}
}
Can confirm this patch solves the issue
Fixed the issue with patch #185 for me after updating to the module first to 7.x-2.7
#20 is working for me, thx @nord102
This patch fixed it for me
michael.vdwalle@dropsolid.com → created an issue.
Patch is working
michael.vdwalle@dropsolid.com → created an issue.
working for me, Thx!
Works for me, Thx!
Also fixes the limitation to the target bundles instead of all vocabulary terms.
michael.vdwalle@dropsolid.com → created an issue.
michael.vdwalle@dropsolid.com → created an issue.