Add per-image transparency checkerboard toggle for markdown content
What does this MR do and why?
Add per-image transparency checkerboard toggle for markdown content
Images with transparency can be invisible when their content matches the page background color. This adds a toggle button (visible on hover) to each image in rendered markdown that enables a checkerboard background pattern, making transparent areas visible in any theme.
It does not show the button when the image either can't be transparent (e.g. JPEG file), or the PNG file has no transparent pixel at all.
Changelog: added
- Tested in Chrome
- Tested in Safari
- Tested in Firefox
- Tested on mobile (will verify a real mobile device once the change is on staging)
Screenshots or screen recordings
Text editor
| Before | After |
|---|---|
When using keyboard instead of mouse/touchpad:
Diff View
| Before | After |
|---|---|
|
|
|
|
How to set up and validate locally
Prerequisites
Prepare a transparent image. You can create them using the tool Transparent PNG Creator or download the following examples
Text editors
- Go to any page with a comment box, e.g. http://gdk.test:3000/flightjs/Flight/-/issues/9
- Add a comment / note / description including a transparent image
- Click on preview and hover over the image to see the button. Toggle transparency button
- Save the comment / note / description and hover over the image to see the button. Toggle transparency button
- Repeat steps 2-4 in dark mode
- Upload another image, e.g. a JPG, and repeat the previous steps. There should be no button on hover.
- Upload a PNG, but without any transparency, and repeat the previous steps. There should be no button on hover.
Diff CSS View
To check the changes related to the diff.scss file, check any MR or commit which adds a transparent image. If you do not have one, execute the following steps:
- Go to any project's repository, e.g. http://gdk.test:3000/flightjs/Flight/-/tree/master
- Click on the plus button and 'Upload file'
- In the modal, drag drop a transparent image.
- Set branch to 'Commit to a new branch'
- Hit 'Commit changes'
- Create the merge request to have it available also in future
- Go to the changes / diff view
- If you want to check for the code, highlight the image and check for the
imgtag in the HTML
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #22133 (closed)








