Skip to content
Snippets Groups Projects
Commit 22ee9bdb authored by catch's avatar catch
Browse files

Issue #3319601 by pooja_sharma, sunlix, bkosborne, quietone, smustgrave,...

Issue #3319601 by pooja_sharma, sunlix, bkosborne, quietone, smustgrave, longwave, lendude: Media image thumbnail incorrectly ends up as NULL when it should be an empty string
parent 816c106e
Branches
Tags
16 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3478Issue #3337882: Deleted menus are not removed from content type config,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #315894 passed with warnings
Pipeline: drupal

#315897

    ......@@ -144,7 +144,7 @@ public function getMetadata(MediaInterface $media, $name) {
    return $uri;
    case 'thumbnail_alt_value':
    return $media->get($this->configuration['source_field'])->alt ?: parent::getMetadata($media, $name);
    return $media->get($this->configuration['source_field'])->alt ?? parent::getMetadata($media, $name);
    }
    return parent::getMetadata($media, $name);
    ......
    ......@@ -8,6 +8,9 @@
    use Drupal\media\Entity\Media;
    use Drupal\user\Entity\Role;
    use Drupal\user\RoleInterface;
    use Drupal\field\Entity\FieldConfig;
    use Drupal\file\Entity\File;
    use Drupal\Tests\TestFileCreationTrait;
    /**
    * Tests the Media overview page.
    ......@@ -16,6 +19,8 @@
    */
    class MediaOverviewPageTest extends MediaFunctionalTestBase {
    use TestFileCreationTrait;
    /**
    * {@inheritdoc}
    */
    ......@@ -185,4 +190,50 @@ public function testMediaOverviewPage(): void {
    $assert_session->linkByHrefExists('/media/' . $media3->id());
    }
    /**
    * Tests the display of the alt attribute.
    */
    public function testImageAltTextDisplay(): void {
    $this->drupalLogin($this->adminUser);
    $media_type = $this->createMediaType('image');
    $media_type_id = $media_type->id();
    $media_type->setFieldMap(['name' => 'name']);
    $media_type->save();
    /** @var \Drupal\field\FieldConfigInterface $field */
    $field = FieldConfig::load("media.$media_type_id.field_media_image");
    $settings = $field->getSettings();
    $settings['alt_field'] = TRUE;
    $settings['alt_field_required'] = FALSE;
    $field->set('settings', $settings);
    $field->save();
    $file = File::create([
    'uri' => $this->getTestFiles('image')[0]->uri,
    ]);
    $file->save();
    // Set the alt text to an empty string.
    $media = Media::create([
    'name' => 'Custom name',
    'bundle' => $media_type_id,
    'field_media_image' => [
    [
    'target_id' => $file->id(),
    'alt' => '',
    'title' => 'default title',
    ],
    ],
    ]);
    $media->save();
    $this->drupalGet('/admin/content/media');
    // Confirm that the alt text attribute is present.
    $assert_session = $this->assertSession();
    $element = $assert_session->elementAttributeExists('css', 'td.views-field-thumbnail__target-id img', 'alt');
    $this->assertSame('', (string) $element->getAttribute('alt'));
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment