Markdown image paste regressions #13096

Closed
opened 2025-11-02 10:30:32 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @wxiaoguang on GitHub (Jun 3, 2024).

Regression of Downscale pasted PNG images based on metadata #29123 :

  1. The pasted image is not clickable (unable to view the full image)
  2. The URL path doesn't contain sub-path if the Gitea instance is deployed under a sub-path.
    • From discord report: Pasting image from the clipboard the Javascript (Paste.js) embeds the image via html code but the src attribute is set to value: /attachments/<GUID>. Using a configuration in which the Gitea application is served on a subpath of the domain name, for example: https://domain.name/git the image is not rendered.
Originally created by @wxiaoguang on GitHub (Jun 3, 2024). Regression of Downscale pasted PNG images based on metadata #29123 : 1. The pasted image is not clickable (unable to view the full image) 2. The URL path doesn't contain sub-path if the Gitea instance is deployed under a sub-path. * From discord report: Pasting image from the clipboard the Javascript (Paste.js) embeds the image via html code but the src attribute is set to value: `/attachments/<GUID>`. Using a configuration in which the Gitea application is served on a subpath of the domain name, for example: `https://domain.name/git` the image is not rendered.
GiteaMirror added the issue/regression label 2025-11-02 10:30:32 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Jun 3, 2024):

@silverwind

@wxiaoguang commented on GitHub (Jun 3, 2024): @silverwind
Author
Owner

@silverwind commented on GitHub (Jun 3, 2024):

Both issues indicate there is some processing that works on ![]() images, but not on the <img> variant, so it's not a direct regression from that PR because <img> is supported since a long time, it just was never noticed.

@silverwind commented on GitHub (Jun 3, 2024): Both issues indicate there is some processing that works on `![]()` images, but not on the `<img>` variant, so it's not a direct regression from that PR because `<img>` is supported since a long time, it just was never noticed.
Author
Owner

@silverwind commented on GitHub (Jun 3, 2024):

Can confirm above suspicion, there is transformImage which apparently is never applied on user-supplied <img> tags because maybe Goldmark does not emit it as ast.Image or something.

@silverwind commented on GitHub (Jun 3, 2024): Can confirm above suspicion, there is [transformImage](https://github.com/go-gitea/gitea/blob/aace3bccc3290446637cac30b121b94b5d03075f/modules/markup/markdown/transform_image.go#L15) which apparently is never applied on user-supplied `<img>` tags because maybe Goldmark does not emit it as `ast.Image` or something.
Author
Owner

@silverwind commented on GitHub (Jun 3, 2024):

Yeah so this is no easy fix in backend because <img> tags do not go through goldmark AST processing I think, they likely go through as raw html so need to introduce the wrapper link here:

aace3bccc3/modules/markup/html.go (L399)

@silverwind commented on GitHub (Jun 3, 2024): Yeah so this is no easy fix in backend because `<img>` tags do not go through goldmark AST processing I think, they likely go through as raw html so need to introduce the wrapper link here: https://github.com/go-gitea/gitea/blob/aace3bccc3290446637cac30b121b94b5d03075f/modules/markup/html.go#L399
Author
Owner

@wxiaoguang commented on GitHub (Jun 4, 2024):

Actually it is a regression. No matter how markdown / img work, as an end users:

  1. I would like to click an image to show the full size (especially when it is a full-size screenshot)
  2. I would like to deploy Gitea under a sub-path and paste images into the editor

I do not care about <img> or something else, but now:

  1. I can't
  2. I can't

As a developer, I think there is an undefined / unclear behavior for the embedded <img> tag when it has a relative src link. But I do not think it's worth to make it more complex than it should be at the moment.

@wxiaoguang commented on GitHub (Jun 4, 2024): Actually it is a regression. No matter how markdown / img work, as an end users: 1. I would like to click an image to show the full size (especially when it is a full-size screenshot) 2. I would like to deploy Gitea under a sub-path and paste images into the editor I do not care about `<img>` or something else, but now: 1. I can't 2. I can't ---- As a developer, I think there is an undefined / unclear behavior for the embedded `<img>` tag when it has a relative `src` link. But I do not think it's worth to make it more complex than it should be at the moment.
Author
Owner

@wxiaoguang commented on GitHub (Jun 4, 2024):

-> Make pasted "img" tag has the same behavior as markdown image #31235

@wxiaoguang commented on GitHub (Jun 4, 2024): -> Make pasted "img" tag has the same behavior as markdown image #31235
Author
Owner

@silverwind commented on GitHub (Jun 4, 2024):

I would like to click an image to show the full size (especially when it is a full-size screenshot)

At least Firefox has the built-in on all images "Open image in new tab" 😉

@silverwind commented on GitHub (Jun 4, 2024): > I would like to click an image to show the full size (especially when it is a full-size screenshot) At least Firefox has the built-in on all images "Open image in new tab" 😉
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13096