Browse Source

Merge branch '8.x-1.x' of github.com:Islandora/islandora

main
dannylamb 5 years ago
parent
commit
8dc842af22
  1. 2
      modules/islandora_text_extraction/islandora_text_extraction.module

2
modules/islandora_text_extraction/islandora_text_extraction.module

@ -34,11 +34,11 @@ function islandora_text_extraction_media_presave(MediaInterface $media) {
return; return;
} }
$text = $media->get('field_edited_text')->getValue(); $text = $media->get('field_edited_text')->getValue();
if (!$text) {
$file_id = $media->get('field_media_file')->getValue()[0]['target_id']; $file_id = $media->get('field_media_file')->getValue()[0]['target_id'];
$file = File::load($file_id); $file = File::load($file_id);
$data = file_get_contents($file->getFileUri()); $data = file_get_contents($file->getFileUri());
$data = nl2br($data); $data = nl2br($data);
if ($text !== $data) {
$media->set('field_edited_text', $data); $media->set('field_edited_text', $data);
$media->field_edited_text->format = 'basic_html'; $media->field_edited_text->format = 'basic_html';
} }

Loading…
Cancel
Save