1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

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
This commit is contained in:
epriestley 2014-05-01 07:18:29 -07:00
parent e8cebb7da5
commit c9dc554cb9
3 changed files with 14 additions and 1 deletions

View file

@ -55,6 +55,7 @@ final class PhabricatorRemarkupRuleEmbedFile
'float' => false, 'float' => false,
'width' => null, 'width' => null,
'height' => null, 'height' => null,
'alt' => null,
); );
if ($option_string) { if ($option_string) {
@ -112,6 +113,10 @@ final class PhabricatorRemarkupRuleEmbedFile
} }
} }
if (isset($options['alt'])) {
$attrs['alt'] = $options['alt'];
}
$img = phutil_tag('img', $attrs); $img = phutil_tag('img', $attrs);
$embed = javelin_tag( $embed = javelin_tag(

View file

@ -36,10 +36,17 @@ final class PhabricatorRemarkupRuleMeme
$options['src'].' <'.PhabricatorEnv::getProductionURI($uri).'>'. $options['src'].' <'.PhabricatorEnv::getProductionURI($uri).'>'.
($options['below'] != '' ? "\n\"{$options['below']}\"" : ''); ($options['below'] != '' ? "\n\"{$options['below']}\"" : '');
} else { } else {
$alt_text = pht(
'Macro %s: %s %s',
$options['src'],
$options['above'],
$options['below']);
$img = phutil_tag( $img = phutil_tag(
'img', 'img',
array( array(
'src' => (string)$uri, 'src' => (string)$uri,
'alt' => $alt_text,
)); ));
} }

View file

@ -347,7 +347,7 @@ from clipboard into the text area.
You can set file display options like this: 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: Valid options are:
@ -360,6 +360,7 @@ Valid options are:
text text
- **width** Scale image to a specific width. - **width** Scale image to a specific width.
- **height** Scale image to a specific height. - **height** Scale image to a specific height.
- **alt** Provide alternate text for assistive technologies.
== Embedding Countdowns == Embedding Countdowns