-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Favicon not used when viewing files #19109
Comments
Favicons are now SVG, so |
Probably a redirect would be better so that browsers don't hit both and cache both |
If this isn't already being tackled and someone is willing to give a pointer I'd be happy to take a look at fixing this issue :) |
You can add the redirect right after Lines 97 to 100 in 04fcf23
Note that I'm not sure if browser are going to accept such a redirect on favicon, but it's worth a try and won't hurt even if it's there. |
Seems that the correct favicon is stored at |
@silverwind it seems that the custom favicon at that path does not exist if the default one is used, meaning that redirecting to it may result in no favicon at all. Is there a better implementation that should allow me to remedy that? Here's my current solution: routes.Get("/favicon.ico", func(w http.ResponseWriter, req *http.Request) {
faviconPath := ""
res, err := http.Get(path.Join(setting.StaticURLPrefix, "/assets/img/favicon.ico"))
if err != nil || res.StatusCode != 200 {
faviconPath = "/favicon.ico"
} else {
faviconPath = "/assets/img/favicon.ico"
}
http.Redirect(w, req, path.Join(setting.StaticURLPrefix, faviconPath), 301)
}) |
Redirect `/favicon.ico` to `/assets/img/favicon.png`. Fix #19109
Awesome! Thank you, all! :-) |
…9130) Redirect `/favicon.ico` to `/assets/img/favicon.png`. Fix go-gitea#19109
…9130) Redirect `/favicon.ico` to `/assets/img/favicon.png`. Fix go-gitea#19109
Gitea Version
1.15.9
Operating System
FreeBSD 13
Browser Version
Firefox 98.0
Can you reproduce the bug on the Gitea demo site?
No
Description
Cannot reproduce at try.gitea.io because it does not use a non-standard favicon. See this file on my self-hosted Gitea instance as an example.
When looking at a file directly in the browser, such as an avatar or PDF file, the default favicon is used instead of the custom favicon. At least in Firefox, the browser displays the favicon at
example.com/favicon.ico
when viewing a file. On HTML pages, the browser correctly usesexample.com/assets/img/logo.svg
.I have configured the favicon by adding the files
favicon.ico
,favicon.png
,logo.png
, andlogo.svg
to$GITEA_CUSTOM/public/img/
.Screenshots
On the left: correct favicon is used for an HTML page.
On the right: default favicon is used for an image.
The text was updated successfully, but these errors were encountered: