-
-
Notifications
You must be signed in to change notification settings - Fork 829
Add alt attribute to image on PCPInfo template. #21808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(Standard links)
|
@agh1 this feels like something you know best practices for |
CRM/PCP/Page/PCPInfo.php
Outdated
@@ -185,10 +185,11 @@ public function run() { | |||
if (!empty($entityFile)) { | |||
$fileInfo = reset($entityFile); | |||
$fileId = $fileInfo['fileID']; | |||
$altText = $fileInfo['description'] ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because 'description'
is not automatically html-escaped (per https://github.com/civicrm/civicrm-core/blob/5.43/CRM/Utils/API/HTMLInputCoder.php#L55) it needs to be escaped here before inserting it into html.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I've updated this to use htmlspecialchars
, but to be honest I wasn't sure if CiviCRM has a better function to be using here - let me know if so!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works. Thanks.
@braders thanks for this PR, this looks good to go, but it would be helpful if you squashed the 2 commits (which you can do with |
It is an accessibility best-practice that all images should have alt text. If a description has been provided, we use that text, otherwise an empty alt text is used (i.e. the image is treated as decorative)
8691f56
to
7546e57
Compare
@colemanw Rebased. Thanks |
For what it's worth, I'm not opposed to the alt attribute always being blank (i.e. treating the image as decorative). Given that the description is otherwise not displayed on the PCP page, using it as alt text feels appropriate, but I don't feel strongly either way. |
I actually do think this is an improvement--it just needs to be followed back to the source a little more. |
It is an accessibility best-practice that all images should have alt text.
If a description has been provided, we use that text,
otherwise an empty alt text is used (i.e. the image is treated as decorative)