- 🇨🇦Canada mmaranao Calgary, AB
The work around from @Juanjol worked for me as well! Is there a fix yet for tranlations?
- Status changed to Needs review
over 1 year ago 8:31am 6 April 2023 Here's a first patch for this, it implements the solution proposed in the IS, so far it comes without any tests.
- 🇮🇳India TanujJain-TJ
Fixed CCF on #16, keeping the status to needs work as it still needs tests.
The last submitted patch, 17: 3232414-17.patch, failed testing. View results →
- Status changed to Needs work
over 1 year ago 5:44am 7 April 2023 - 🇮🇳India Akram Khan Cuttack, Odisha
adding updated patch and to fix the error
- 🇧🇪Belgium joevagyok
The patch fails because there is a specific assertion in the test to ensure that changing non-primary properties like the "alt" will not trigger an update implemented in this issue here: #3192059: Use the source field main property to determine if the source field has changed →
By doing this, we are going against that requirement. However, looking into and focus on the related issue here: ✨ Expose triggering update of media metadata + thumbnail to end users Needs work would bring us closer to a more robust solution. I would say let's focus on that, since we have a workaround in #8 for the meantime.
- 🇫🇮Finland iamfredrik
I tried implementing the presave function in #8 but couldn't get it to work. I put the code from #8 in mymodule/src/MediaImage.php, and then the following code in mymodule.module.
use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; function mymodule_entity_type_build(array &$entity_types) { if (isset($entity_types['media'])) { $entity_types['media']->setClass('Drupal\mymodule\Entity\MediaImage'); } }
Help with implementing the workaround correctly would be much appreciated.
- 🇺🇸United States papagrande US West Coast
@iamfredrik, I implemented @Juanjol's "rather messy workaround" in #8 (the first one) and it's working just fine. I suggest going with that until we can get this issue resolved.
- 🇫🇮Finland iamfredrik
@PapaGrande, I tried both workarounds and none of them worked.
- 🇺🇸United States rex.barkdoll
Hi all,
I've been trying to implement this and nothing is working.I've created my own module, but nothing in #8 is doing anything (assuming I put the code in the .module file).
I've also tried the patches and they don't apply. I'm trying to apply them to drupal/media, so let me know if that's incorrect.
Thanks for any insight or help you can provide. - 🇺🇸United States ian.ssu
@rec.barkdoll #8 seems to work for me in Drupal 10.2.x I've added a check to prevent warning with other media types (i.e document).
my_module.module
/** * Implements hook_ENTITY_TYPE_presave(). */ function my_module_media_presave(EntityInterface $entity): void { /** @var \Drupal\media\Entity\Media $entity */ if ($entity->bundle() === 'image' && $entity->hasField('thumbnail') && $entity->hasField('field_media_image') ) { $entity->thumbnail->alt = $entity->field_media_image->alt; } }
- 🇷🇴Romania bogdan.racz
I have updated the patch #19, as it failed when adding new translations on the media - the original didn't had the translation, but the hasChanged method was checking it.
Please check the patch and the interdiff.Note: This is a not-recommeded workaround until ✨ Expose triggering update of media metadata + thumbnail to end users Needs work is ready.
- 🇺🇸United States davedg629
I tried the workarounds proposed in #8 and #26. They worked for some images, but not others and I couldn't figure out why.
I implemented the patch from #27 and it's working for all images I tested..