Skip to content

Add alt attribute to various images#14405

Merged
steverep merged 30 commits into
home-assistant:devfrom
transplier:a11y-low-hanging-img-alt-tags
Dec 29, 2022
Merged

Add alt attribute to various images#14405
steverep merged 30 commits into
home-assistant:devfrom
transplier:a11y-low-hanging-img-alt-tags

Conversation

@transplier
Copy link
Copy Markdown
Contributor

@transplier transplier commented Nov 18, 2022

Proposed change

Responding to issue #14178, figured I'd make this my first contribution to get a feel for the codebase.

  • Add Alternate Text config option for Picture Card, Picture Entity, and picture card header/footer.
  • Add blank alt attribute to purely decorative images.
  • Add new translation strings and use them for the alt attribute on images which are not decorative.
  • I did not hit all image tags, but this is most of them. For example, I did not modify the Google Cast stuff, as I lack the hardware to test this.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

# Example usage of alt_text property

cards:
  - type: picture
    image: https://demo.home-assistant.io/stub_config/t-shirt-promo.png
    tap_action:
      action: none
    hold_action:
      action: none
    alt_text: A person wearing a Home Assistant promotional t-shirt.
  - type: picture-entity
    show_state: true
    show_name: true
    camera_view: auto
    entity: weather.forecast_hamilton_dev_test
    image: https://demo.home-assistant.io/stub_config/bedroom.png
    name: Test Name
    alt_text: Some alt text
  - type: entities
    entities:
      - sensor.freebsd_router_kib_s_received
      - sensor.freebsd_router_kib_s_sent
      - sensor.freebsd_router_external_ip
    header:
      type: picture
      image: >-
        https://www.home-assistant.io/images/lovelace/header-footer/balloons-header.png
      tap_action:
        action: none
      hold_action:
        action: none
      alt_text: Balloons in a festive arrangement.
    footer:
      type: picture
      image: >-
        https://www.home-assistant.io/images/lovelace/header-footer/balloons-header.png
      tap_action:
        action: none
      hold_action:
        action: none
      alt_text: A line of balloons.

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@home-assistant
Copy link
Copy Markdown

Hello @PROGMAN32,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting "Author Name" and "email@address.com" for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

Comment thread gallery/src/pages/components/ha-alert.ts Outdated
Comment thread hassio/src/addon-view/info/hassio-addon-info.ts
Comment thread src/components/ha-addon-picker.ts Outdated
Comment thread src/components/ha-config-entry-picker.ts
Comment thread src/components/tile/ha-tile-image.ts Outdated
Comment thread src/dialogs/image-cropper-dialog/image-cropper-dialog.ts Outdated
Comment thread src/onboarding/integration-badge.ts
Comment thread src/panels/config/areas/ha-config-area-page.ts Outdated
Comment thread src/panels/config/energy/components/ha-energy-grid-settings.ts
Comment thread src/panels/config/energy/components/ha-energy-grid-settings.ts
Comment thread src/panels/config/energy/dialogs/dialog-energy-solar-settings.ts
Comment thread src/panels/config/hardware/ha-config-hardware.ts
Comment thread src/panels/config/integrations/ha-domain-integrations.ts
Comment thread src/panels/config/integrations/ha-integration-header.ts
Copy link
Copy Markdown
Member

@steverep steverep left a comment

Choose a reason for hiding this comment

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

About half way through...

Comment thread src/translations/en.json Outdated
Comment thread src/translations/en.json Outdated
Comment thread src/panels/config/areas/ha-config-area-page.ts Outdated
Comment thread src/translations/en.json Outdated
Comment thread src/panels/lovelace/editor/structs/entities-struct.ts Outdated
Comment thread src/panels/lovelace/cards/types.ts Outdated
Comment thread src/panels/lovelace/cards/types.ts
Comment thread src/dialogs/image-cropper-dialog/image-cropper-dialog.ts Outdated
Comment thread src/panels/config/repairs/ha-config-repairs.ts
Comment thread src/panels/config/devices/ha-config-device-page.ts
Comment thread src/panels/lovelace/editor/config-elements/hui-picture-entity-card-editor.ts Outdated
Comment thread gallery/src/pages/components/ha-alert.ts Outdated
Comment thread src/components/tile/ha-tile-image.ts Outdated
@steverep
Copy link
Copy Markdown
Member

@PROGMAN32 I'm finally done reviewing. Just some fairly minor changes needed.

@steverep
Copy link
Copy Markdown
Member

Just wanted to check in... do you think you'll have time to make some changes soon? I don't want to see this work go to waste.

@transplier
Copy link
Copy Markdown
Contributor Author

Just wanted to check in... do you think you'll have time to make some changes soon? I don't want to see this work go to waste.

Life got in the way, but I'm working on this again! Just finished setting up a dev env on my new portable setup and will start going through all the helpful comments.

Comment thread gallery/src/pages/components/ha-alert.ts
Comment thread src/dialogs/image-cropper-dialog/image-cropper-dialog.ts
Comment thread src/panels/lovelace/components/hui-image.ts Outdated
@steverep steverep enabled auto-merge (squash) December 29, 2022 01:04
@steverep steverep added this to the 2023.1 milestone Dec 29, 2022
@steverep
Copy link
Copy Markdown
Member

Pushed this one across the finish line for you to get it in the next release. 😮‍💨

Just need to fix the doc PR.

@steverep steverep merged commit 5c2fcd7 into home-assistant:dev Dec 29, 2022
@transplier
Copy link
Copy Markdown
Contributor Author

Thanks. I didn't have much time to dedicate to this post holiday.

@steverep
Copy link
Copy Markdown
Member

steverep commented Jan 7, 2023

No problem. Happy new year!

@github-actions github-actions Bot locked and limited conversation to collaborators Jan 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Images without alternative text

3 participants