Browse Source

Revert "update field_edited_text when different from the file contents (#769)" (#770)

This reverts commit 163a621bc4.
pull/773/head
dannylamb 5 years ago committed by GitHub
parent
commit
3c969bf14f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      modules/islandora_text_extraction/islandora_text_extraction.module

10
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();
$file_id = $media->get('field_media_file')->getValue()[0]['target_id']; if (!$text) {
$file = File::load($file_id); $file_id = $media->get('field_media_file')->getValue()[0]['target_id'];
$data = file_get_contents($file->getFileUri()); $file = File::load($file_id);
$data = nl2br($data); $data = file_get_contents($file->getFileUri());
if ($text !== $data) { $data = nl2br($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