Skip to content

Markdown attribute syntax for images

Brett Walker requested to merge 28118-markdown-attribute-syntax-for-images into master

What does this MR do and why?

Feature flag: :markdown_image_attributes

Support inline attributes for specifying width and height for markdown images. This is based the syntax specified in https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/attributes.md.

For example,

![](image.jpg){width=75%}

create the html

<img src="image.jpg" width="75%">

Only height and width are supported - there is no support for classes or other other attributes.

Screenshots or screen recordings

Screenshot_2022-11-29_at_2.00.30_PM

How to set up and validate locally

  1. enable the feature flag, Feature.enable(:markdown_image_attributes)

  2. In a issue description or comment, add the following markdown

    ![](https://about.gitlab.com/images/press/logo/png/gitlab-logo-500.png){ width=50 }
    ![](https://about.gitlab.com/images/press/logo/png/gitlab-logo-500.png){ width=75% }

    you should see the different sized images as in the screenshot above

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #28118 (closed)

Edited by Brett Walker

Merge request reports