I want to get the file entity out of an media image bundle to the get the filename to check if the image is cmyk or not.
/**
* Implements hook_ENTITY_TYPE_presave().
*/
function hook_media_presave(MediaInterface $entity) {
if ($entity->bundle() == 'image') {
$field_definitions = $entity->getFieldDefinitions();
foreach ($field_definitions as $field_definition) {
if ($field_definition->getType() 'image') {
// get File entity here.
}
}
}
}
How do I do this?