Skip to content
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

Add the ability to add alt text to images #2630

Open
2 tasks
doom-cat opened this issue Jul 7, 2024 · 0 comments
Open
2 tasks

Add the ability to add alt text to images #2630

doom-cat opened this issue Jul 7, 2024 · 0 comments

Comments

@doom-cat
Copy link

doom-cat commented Jul 7, 2024

Describe the problem

Currently, there appears to be no means to add alt text to images in Word2007 Writer. Alt text is important because it is displayed in lieu of the image if the image fails to load for some reason. It is also an important accessibility feature, since it allows screen readers to describe the content of an image if the image is not visible to a user.

Describe the expected behavior

The addImage usage should change from:
$section->addImage($src, [$style]);
to:
$section->addImage($src, [$style], [string $altText]);

I have code that adds this capability, but it would help to know if the $name variable is used with images, so that I can avoid conflicts in the order of Image properties.
In file src/PhpWord/Element/Image.php, line 149 shows the following:
public function __construct($source, $style = null, $watermark = false, $name = null)

The $name variable is not addressed in any documentation that I found, but it does appear on line 73 of tests/PhpWordTests/Element/ImageTest.php. If it is not used, then I would like to change the above constructor as follows, since it will provide a simpler call to add an image that is not a watermark:
public function __construct($source, $style = null, $altText = null, $watermark = false, $name = null)

If $name is used, then I will put the new $altText property at the end:
public function __construct($source, $style = null, $watermark = false, $name = null, $altText = null)

Priority

  • I want to crowdfund the feature (with @algora-io) and fund a community developer.
  • I want to pay the feature and fund a maintainer for that. (Contact @Progi1984)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant