Skip to content

Conversation

@DanGastardelli
Copy link
Contributor

@DanGastardelli DanGastardelli commented Oct 4, 2024

Allow input of alternative text for collection and community logos/thumbnails

References

Fixes #1306
Requires DSpace/DSpace#9875

This change was addressed in #1306, which now allows detailed description of thumbnail images of items, collections, and community logos (also recognized by screen readers).

Description

First, logic was created using OnInit in the thumbnail component to bring the thumbnail description value into the "alt" text contained in the image tag in the HTML. Fields were then created for insertion in the creation and editing of communities and collections that allowed the insertion of details about the logos involved and finally the creation of translation keys for these fields.

Instructions for reviewers

Firstly, you need to use the backend of this PR DSpace/DSpace#9875.

List of changes in this PR:

  • Creation of logic in the thumbnail component to extract the thumbnail description of the item (using the onInit function and using variables created to obtain the thumbnail description through the thumbnail object);
  • Make conditionals in the html to check if there is a custom description and pass it in the alt of the thumbnail;
  • A field was created in the community form and collection form using the "dspace.thumbnail.description" metadata to accept descriptions;
  • Functions have been created in the collection model and community model that provide thumbnail descriptions of collections and communities;
    *In the html of the components of the community page and the collection page, conditionals were inserted and check if there is a custom description and insert the variable with the description in the alternative text.
  • Created appropriate translation keys "community.form.thumbnail" and "collection.form.thumbnail" for the field created for communities and collections (translations done in English, Portuguese and Spanish)

Include guidance on how to test or review your PR.

To test, simply create a collection and community that contains a logo. In the “Thumbnail description” field, fill in the data for this logo and finally inspect the logo or use a screen reader on the logo to validate the description entered. Now as for the items, just insert a bitstream and create the thumb by running filter-media in the backend. After that, go to item editing and go to the bitstream tab and edit the thumbnail description and then go to the item and hover your screen reader over the image or inspect it to see if the description matches what you entered.

@github-actions
Copy link

github-actions bot commented Oct 8, 2024

Hi @DanGastardelli,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@github-actions
Copy link

github-actions bot commented Nov 1, 2024

Hi @DanGastardelli,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@github-actions
Copy link

Hi @DanGastardelli,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@github-actions
Copy link

github-actions bot commented Jan 6, 2025

Hi @DanGastardelli,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@github-actions
Copy link

github-actions bot commented Feb 6, 2025

Hi @DanGastardelli,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@github-actions
Copy link

Hi @DanGastardelli,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@github-actions
Copy link

Hi @DanGastardelli,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

@github-actions
Copy link

Hi @DanGastardelli,
Conflicts have been detected against the base branch.
Please resolve these conflicts as soon as you can. Thanks!

Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DanGastardelli : We talked about this PR as a team in today's Developers Meeting. The overall feedback was positive, but there was a suggestion to avoid creating a new metadata field for this "alt" text. See comment inline below for the suggestion.

* Corresponds to the metadata field dspace.thumbnail.description
*/
get descriptionThumbnail(): string {
return this.firstMetadataValue('dspace.thumbnail.description');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was suggested in today's meeting that the more appropriate place to store the "alt" text for a Bitstream would be on the Bitstream object itself in the dc.description field. This has two main benefits:

  • It would avoid needing to create a new metadata field on the backend.
  • It'd also be better to store this information on the Bitstream as the "alt" text is a description of the Bitstream, and not something that belongs to the Collection. That way, if the Bitstream logo changes, then the old "alt" text goes away and new text comes with the new Bitstream.

Copy link
Member

@artlowel artlowel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @DanGastardelli!

if (this.thumbnail){
if ('payload' in this.thumbnail) {
this.listenThumbnail = this.thumbnail;
this.customDescription = this.listenThumbnail.payload.metadata['dc.description'][0].value;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will throw an error if there's no description. Better do something like

Suggested change
this.customDescription = this.listenThumbnail.payload.metadata['dc.description'][0].value;
const bitstream = this.listenThumbnail.payload;
if (bitstream && bitstream.hasMetadata('dc.description')) {
this.customDescription = bitstream.firstMetadataValue('dc.description');
}

}
<!-- don't use *ngIf="!isLoading" so the thumbnail can load in while the animation is playing -->
@if (src() !== null) {
@if (src() && customDescription === undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If customDescription is an empty string, it will not be undefined and this default alt text won't be used

Comment on lines 20 to 27
@if (src() && customDescription !== undefined) {
<img class="thumbnail-content img-fluid"
[class.d-none]="isLoading()"
[src]="src() | dsSafeUrl"
[alt]="customDescription"
(error)="errorHandler()"
(load)="successHandler()"/>
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're duplicating a lot of code here, simply for the alt property. Perhaps it's a better idea to move the logic to the ts file, and have a this.altText property that's always defined, and contains the customDescription if it exists (and isn't empty), and the i18n message otherwise

@DanGastardelli
Copy link
Contributor Author

Hi @artlowel!

I made some changes to reduce code repetition and implemented the suggestion given for the thumbnail component condition.

Looking forward to your feedback,
Daniel Pais (Neki-it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 👀 Under Review

Development

Successfully merging this pull request may close these issues.

Allow entry of alt-text for collection and community logos / thumbnails

3 participants