From c9dc554cb94fb8fc893a1478c3fb72a9369ddc03 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 1 May 2014 07:18:29 -0700 Subject: [PATCH] Allow users to provide alt text for image embeds Summary: Ref T4843. - Add an `alt` attribute so users can provide alternate text for `{Fnnn}`. - Add an `alt` attribute to image macros. Test Plan: Embedded an image with `alt` and a macro, inspected HTML source to verify the `alt` attribute was present. Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T4843 Differential Revision: https://secure.phabricator.com/D8925 --- .../files/remarkup/PhabricatorRemarkupRuleEmbedFile.php | 5 +++++ .../macro/remarkup/PhabricatorRemarkupRuleMeme.php | 7 +++++++ src/docs/user/userguide/remarkup.diviner | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php b/src/applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php index c631d53fd4..af7d910df0 100644 --- a/src/applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php +++ b/src/applications/files/remarkup/PhabricatorRemarkupRuleEmbedFile.php @@ -55,6 +55,7 @@ final class PhabricatorRemarkupRuleEmbedFile 'float' => false, 'width' => null, 'height' => null, + 'alt' => null, ); if ($option_string) { @@ -112,6 +113,10 @@ final class PhabricatorRemarkupRuleEmbedFile } } + if (isset($options['alt'])) { + $attrs['alt'] = $options['alt']; + } + $img = phutil_tag('img', $attrs); $embed = javelin_tag( diff --git a/src/applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php b/src/applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php index 637d25ffa7..88c754ff37 100644 --- a/src/applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php +++ b/src/applications/macro/remarkup/PhabricatorRemarkupRuleMeme.php @@ -36,10 +36,17 @@ final class PhabricatorRemarkupRuleMeme $options['src'].' <'.PhabricatorEnv::getProductionURI($uri).'>'. ($options['below'] != '' ? "\n\"{$options['below']}\"" : ''); } else { + $alt_text = pht( + 'Macro %s: %s %s', + $options['src'], + $options['above'], + $options['below']); + $img = phutil_tag( 'img', array( 'src' => (string)$uri, + 'alt' => $alt_text, )); } diff --git a/src/docs/user/userguide/remarkup.diviner b/src/docs/user/userguide/remarkup.diviner index b15dcc0e35..ab671649e1 100644 --- a/src/docs/user/userguide/remarkup.diviner +++ b/src/docs/user/userguide/remarkup.diviner @@ -347,7 +347,7 @@ from clipboard into the text area. You can set file display options like this: - {F123, layout=left, float, size=full} + {F123, layout=left, float, size=full, alt="a duckling"} Valid options are: @@ -360,6 +360,7 @@ Valid options are: text - **width** Scale image to a specific width. - **height** Scale image to a specific height. + - **alt** Provide alternate text for assistive technologies. == Embedding Countdowns