mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-10 22:06:34 -05:00
Git LFS image linking not possible #2762
Closed
opened 2025-11-02 04:47:18 -06:00 by GiteaMirror
·
16 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.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v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/feature
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#2762
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @diondokter on GitHub (Jan 16, 2019).
8006b1bin footer of the instance)[x]):Description
When linking to an image that is stored in LFS, you get the LFS text. For example:
https://mywebsite.com/diondokter/myrepo/raw/branch/develop/Design/Images/myimage.jpg gives
When linking to the image in markdown, it will not appear which is quite inconvenient.
Can this be resolved?
I can't repro this issue on try.gitea.io because (I suspect) LFS is turned off.
@zeripath commented on GitHub (Jan 20, 2019):
The problem is that we may need the raw route to still actually give the raw file pre-smudge... I hate to say it but what does github do?
@diondokter commented on GitHub (Jan 20, 2019):
I made a quick repo on github. That seems to work fine.
It's public and you can view it here: https://github.com/diondokter/LFS-Test
The first image is in LFS, the second one is not.
Also note that when you go to the LFS image file, it doesn't ask you if you want to see the raw file and actually displays the image. (https://github.com/diondokter/LFS-Test/blob/master/TestImage.jpg)
@zeripath commented on GitHub (Jan 20, 2019):
OK, so github's raw does provide the pointer. https://raw.githubusercontent.com/diondokter/LFS-Test/master/TestImage.jpg
So we probably shouldn't change the results of the raw url. Could you tell me how you linked the image - I'm not quite sure how our wiki works.
@diondokter commented on GitHub (Jan 20, 2019):
If you go to the raw readme file, you can see how it's linked. It's the same in Gitea as it's standard markdown. https://raw.githubusercontent.com/diondokter/LFS-Test/master/README.md
When going to the image itself in the browser, it seems the lfs image and the normal image use different subdomains.
LFS uses 'media.' https://media.githubusercontent.com/media/diondokter/LFS-Test/master/TestImage.jpg
Normal uses 'raw.' https://raw.githubusercontent.com/diondokter/LFS-Test/master/TestImage.gif
I guess that the markdown renderer realizes that the image was an lfs image and links to a different path. In the meanwhile, lfs images are also hosted on the server as actual images.
@zeripath commented on GitHub (Jan 20, 2019):
So we just link using
and the markdown render recognises images and places<img>as appropriate?@diondokter commented on GitHub (Jan 20, 2019):
A normal link is:
'[link text](link url)'.
To show an image you do it like a link, but with an exclamation mark.
''
Here's a markdown cheatsheet: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
@zeripath commented on GitHub (Jan 20, 2019):
OK
rawreplaced withmedia/media/*/mediaMediaNow most of the work to do the lfs download is already in the editor somewhere because I know we detect if a file is LFS and ask if you want to download the LFS version.
@zeripath commented on GitHub (Jan 20, 2019):
@zeripath commented on GitHub (Jan 20, 2019):
OK, if you can could you try building from #5787 and test if that solves your problem?
@diondokter commented on GitHub (Jan 20, 2019):
I've built gitea following the instructions here on github and on the website. (My first time for gitea)
This PR page appears to render the same on this commit as the page I put up on github.
Screenshot of the gitea page:

The functionality seems to be working. Well done!
@zeripath commented on GitHub (Jan 21, 2019):
Ah I've just noticed something very disturbing... If you try to commit an LFS pointer file just as a random file https://github.com/go-gitea/gitea/blob/master/routers/repo/view.go#L185 will mean that it gets assigned as an LFS file.
@zeripath commented on GitHub (Jan 21, 2019):
The correct thing is to query the git attributes then the file
@diondokter commented on GitHub (Jan 21, 2019):
Does it though?
Consider this scenario: I add .png to the lfs attributes and a png to lfs.
Later I remove the .png file from the attributes. The png will still be in lfs, right?
If I'm correct, you should check the file pointer itself.
@zeripath commented on GitHub (Jan 21, 2019):
OK, you have two repositories A and B, A has lfs set up and you commit a file F.jpg which gets pointered to P.jpg. B doesn't have lfs set up, and you manage to get a copy of the pointer file P.jpg and commit that.
On gitea this file P.jpg when browsing B will be said to be a Git LFS file - even though it isn't and my patchset will display P.jpg as a jpeg although when you clone B you won't get any filtering as B doesn't have git-lfs set up.
Similarly, there's a weirdness in github's interface - if you delete the .jpg from the .gitattributes then technically those files stop being lfs - however, github will continue to show them as if they're LFS - they must be storing the filename with the lfs status - which I guess is safe than relying on parsing gitattributes as there may be filters other than lfs that actually end up with adding stuff to the lfs.
@lafriks commented on GitHub (Jan 21, 2019):
I don't thint gitattributes should be taken into account
@zeripath commented on GitHub (Jan 21, 2019):
Hmm, I think .gitattributes and the lfs filter is really the only thing we've really got to detect if a file is LFS or not. I suppose you could come up with another filter with a different name than the default but then you're at the point of making things so difficult for everyone that your repository is very special indeed.
I suspect for my current patchset #5787 it's probably reasonable to assume that if it looks like a pointer, just check if the LFS Oid is in that repository and if so, show it as the object.