[PR #4675] [MERGED] Fix markdown image with link #17459

Closed
opened 2025-11-02 13:32:02 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/4675
Author: @LER0ever
Created: 8/12/2018
Status: Merged
Merged: 10/30/2018
Merged by: @techknowlogick

Base: masterHead: fix/md-image-links


📝 Commits (6)

  • 1b0d525 Fix markdown image with link
  • fdd8ceb Add gitea copyright notice
  • 3b7d5ae add a test for markdown image with link
  • 9a4015c Merge branch 'master' into fix/md-image-links
  • faade68 remove svg related variables
  • a3ba588 Merge branch 'master' into fix/md-image-links

📊 Changes

2 files changed (+21 additions, -22 deletions)

View changed files

📝 modules/markup/markdown/markdown.go (+17 -22)
📝 modules/markup/markdown/markdown_test.go (+4 -0)

📄 Description

This PR fixes the image with link rendering. And therefore resolves #4569 and resolves #5207

Original Behavior

Images with ![alt](imgurl) will be put inside a link to itself, unless it's an svg-file.

The problem is that it hardcoded the svg filetype to be directly rendered in <img> tag, and other file types are rendered like <a><img></a> which causes #4569 and #5207 .

New Behavior in this PR

Images with ![alt](imgurl) will be put inside a link to itself, unless it's already inside a link, which is [![alt](imgurl)](url).
So we don't need to infer from filetype whether the image is a CI image or not.
Also, this matches the Github-Flavored Markdown's behavior on images with links.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/4675 **Author:** [@LER0ever](https://github.com/LER0ever) **Created:** 8/12/2018 **Status:** ✅ Merged **Merged:** 10/30/2018 **Merged by:** [@techknowlogick](https://github.com/techknowlogick) **Base:** `master` ← **Head:** `fix/md-image-links` --- ### 📝 Commits (6) - [`1b0d525`](https://github.com/go-gitea/gitea/commit/1b0d525d3bbcd0efefbfdda4a3ed202fd6c1d970) Fix markdown image with link - [`fdd8ceb`](https://github.com/go-gitea/gitea/commit/fdd8ceb593df27dfb16ef2d5fe14a26ce0fd9d08) Add gitea copyright notice - [`3b7d5ae`](https://github.com/go-gitea/gitea/commit/3b7d5ae99686635d438c86fc7e38321b67113e7a) add a test for markdown image with link - [`9a4015c`](https://github.com/go-gitea/gitea/commit/9a4015c37d2b5f15efebc04e6f25c5d4c711749f) Merge branch 'master' into fix/md-image-links - [`faade68`](https://github.com/go-gitea/gitea/commit/faade68f3cff5186270f1155e23504a40a9500d6) remove svg related variables - [`a3ba588`](https://github.com/go-gitea/gitea/commit/a3ba588a8836aa2fa2192ba7fc72c1bcd266b329) Merge branch 'master' into fix/md-image-links ### 📊 Changes **2 files changed** (+21 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `modules/markup/markdown/markdown.go` (+17 -22) 📝 `modules/markup/markdown/markdown_test.go` (+4 -0) </details> ### 📄 Description **This PR fixes the image with link rendering.** And therefore resolves #4569 and resolves #5207 ### Original Behavior Images with `![alt](imgurl)` will be put inside a link to itself, unless it's an svg-file. The problem is that it hardcoded the svg filetype to be directly rendered in `<img>` tag, and other file types are rendered like `<a><img></a>` which causes #4569 and #5207 . ### New Behavior in this PR Images with `![alt](imgurl)` will be put inside a link to itself, unless it's already inside a link, which is `[![alt](imgurl)](url)`. So we don't need to infer from filetype whether the image is a CI image or not. Also, this matches the Github-Flavored Markdown's behavior on images with links. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 13:32:02 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#17459