Commit fb4c9d36 authored by git's avatar git Committed by Matthew Tift
Browse files

Issue #3209998 by mekal, mtift, alexis_s: Image alt field truncation error

parent d00d831d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ use Drupal\Core\Url;
use Drupal\media\Entity\Media;
use Drupal\npr_api\NprClient;
use Drupal\taxonomy\Entity\Term;
use Drupal\Component\Utility\Unicode;

/**
 * Performs CRUD operations on Drupal nodes using data from the NPR API.
@@ -517,7 +518,7 @@ class NprPullClient extends NprClient {
      if (!empty($caption_field) && $caption_field != 'unused') {
        $caption = $referenced_image->get($caption_field)->value;
        // NOTE: The API doesn't seem to send alt text, so re-using caption.
        $alt = $caption;
        $alt = Unicode::truncate($caption, 512, FALSE, TRUE);
      }
      if (!empty($copyright_field) && $copyright_field != 'unused') {
        $copyright = $referenced_image->get($copyright_field)->value;
@@ -873,7 +874,7 @@ class NprPullClient extends NprClient {
        // Attached the image file to the media item.
        $media_image->set($image_field, [
          'target_id' => $file->id(),
          'alt' => $image->caption->value,
          'alt' => Unicode::truncate($image->caption->value, 512, FALSE, TRUE),
        ]);

        // Map all of the remaining fields except image_title and image_field,