Skip to content

Conversation

@theletterf
Copy link
Contributor

Fixes #1655

When adding images to documentation, users often need to specify sizing parameters (e.g., =50%) in the title attribute. This creates a redundancy issue where the alt text needs to be duplicated as the title before adding the size parameters, resulting in Markdown like:

![Description](/path/to/image.png "Description =50%")

This PR modifies the ImageBlock class to automatically use the alt text as the title value when no explicit title is provided. This allows users to:

  1. Skip the redundant title text when only specifying size parameters:
    ![Description](/path/to/image.png "=50%")

  2. Not have to duplicate information when using image directives.

Changes

  • Modified the FinalizeAndValidate method in ImageBlock.cs to use alt text as the title when title is not specified
  • Updated the documentation to explain this new behavior
  • Updated test cases to reflect the new HTML output that includes title attributes

@theletterf theletterf requested review from a team as code owners July 30, 2025 10:57
@theletterf theletterf self-assigned this Jul 30, 2025
@theletterf theletterf marked this pull request as draft July 30, 2025 11:00
@github-actions
Copy link

github-actions bot commented Jul 30, 2025

🔍 Preview links for changed docs

Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

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

Great QoL improvement 👍

@theletterf
Copy link
Contributor Author

@Mpdreamz Looks like it's not working as intended. Looking at it.

@theletterf theletterf marked this pull request as ready for review July 30, 2025 13:52
@theletterf theletterf requested review from Mpdreamz and reakaleek July 30, 2025 13:52
@theletterf
Copy link
Contributor Author

@Mpdreamz @reakaleek To make things simpler, I've made it so that Alt text always overrides the title, whether it's present or not. In most cases, the titles we have are not useful.

@florent-leborgne
Copy link
Contributor

florent-leborgne commented Jul 30, 2025

This is already super great! Is it possible to also check if the current title is plain "title" and in that case overwrite it with the alt value too? :D
Kind of a safety net

This could also be something we instead flag with a linter for example, if we don't want to bake it in docs-builder :)

Edit: nevermind, just saw your last comment @theletterf :D Perfect

Copy link
Contributor

@florent-leborgne florent-leborgne left a comment

Choose a reason for hiding this comment

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

This is greatttt

…om:elastic/docs-builder into theletterf-alt-images-title-redundancy-fix
Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

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

LGTM!

@theletterf theletterf merged commit ad418ac into main Jul 30, 2025
17 checks passed
@theletterf theletterf deleted the theletterf-alt-images-title-redundancy-fix branch July 30, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Pass ALT text value as title automatically for inline images

5 participants