go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
44.18k stars 5.42k forks source link

Proposal: facilitate getting image sizes added to markdown #27339

Open ell1e opened 11 months ago

ell1e commented 11 months ago

Feature Description

GitLab has image sizes now, has had for a while: (Click for Gitlab image size spec)

![alt text](img/markdown_logo.png){width=100 height=100px}

The huge problem of no image sizes is, that it makes any High-DPI screenshots in technical documentation use impossible. Any logos of a modern project will also likely be High-DPI, so this could affect pretty much every future README that is slightly more polished.

Why bother with that in markdown, in detail: The source of the trouble is that browsers ignore DPI attributes, so any included High-DPI image is going to be way too large unless a proper, smaller display size can be specified. This is not just a style and polish concern, since a High-DPI image can easily be 2x or even 3x too large and be so giant, that it won't even fit on any user's screen and makes the documentation just plain unreadable. So this is not a minor styling concern that would usually have no place in markdown, given markdown is otherwise style agnostic.

Also, this affects basically all documentation of all projects with mobile screenshots or logos, which should be possibly a huge amount or even majority of projects, and most importantly also not just giant corporation ones that might want to be on Gitlab or Github or similar anyway but also small self-hosted ones.

Why make a ticket here and not upstream? Simply because it seems like goldmark seems unlikely to add this into the core project, so if this is ever to arrive in gitea probably someone would need to add an extension or a different markdown library would need to be used. Also, the old Gitea ticket was closed in favor of the upstream discussion but that discussion doesn't seem to be going anywhere.

I hope this can eventually arrive in gitea.

Screenshots

No response

silverwind commented 11 months ago

This is a good idea. I'm also annoyed that uploaded images are rendered too large on GitHub and Gitea because they don't respect DPI scaling.

We could check window.devicePixelRatio when uploading images in JS and reduce the image size with these new attributes. The drawback of this method is that we assume the device uploading the image is also the one that took the image, which is not always correct, but I guess it's better then not doing anything.

ell1e commented 11 months ago

(removed text of me just being confused)

Edit: wasn't directly relevant to the discussion, my bad

silverwind commented 11 months ago

My thought was that most content uploaded is screenshots and if someone with for example pixel ratio 2 uploads a image at 1000x1000, we would reduce that to 500x500 for rendering, so the image would be rendered with the correct amount of CSS pixels.

ell1e commented 11 months ago

(removed text of me just being confused)

Edit 2: nevermind, you're proposing to allow specifying at upload time as an addition, I guess that wouldn't hurt. I somehow thought that it was related to solving the markdown issue, my bad.

ell1e commented 11 months ago

My apologies for the confusion on my side, I get what you mean now. It sounds useful as an addition.

silverwind commented 11 months ago

Maybe it could be a per-user setting "Respect device pixel ratio when uploading images".

ell1e commented 11 months ago

Maybe there could just be a scale adjuster in the "Preview" tab of the comments?

In any case, I really hope the Markdown syntax extension for image sizes can happen for README's and such.