Implements hook_entity_presave().
Transforms default image of image field from array into single value at save.
function image_entity_presave(EntityInterface $entity, $type) {
$field = FALSE;
if ($entity instanceof FieldInstance) {
$field = $entity
->getField();
}
elseif ($entity instanceof Field) {
$field = $entity;
}
if ($field && $field->type == 'image' && is_array($entity->settings['default_image'])) {
if (!empty($entity->settings['default_image'][0])) {
$entity->settings['default_image'] = $entity->settings['default_image'][0];
}
else {
$entity->settings['default_image'] = 0;
}
}
}