I am using the document media type for pdfs. I am also utilizing the field mappings for:
- MIME Type
- File size
- and I will be adding a field mapping for the pdfs subject as well using a Media source plugin.
These are working as expected when I save the media entity; however, I have the additional requirement that the Name and Subject fields will be auto-populated when a file is initially selected. The user creating the media entity will then be able to see the name and subject in their respective fields and can change these if desired.
I have tried adding the ajax call for the file field in a form alter; however, I don't believe that this will work because the managed_file type already uses ajax.
I have also tried to create a custom Element using the idea from another question but that doesn't seem to be working either. The field is in a widget, and so when I update the field type like this:
$form['field_media_document']['widget']['#type'] = 'my_managed_file';, it seems my callback is never triggered.
Thank you in advance for any ideas or insights on how to get the pdf metadata to prepopulate the media fields after selecting the file.