diff --git a/modules/markup/orgmode/orgmode.go b/modules/markup/orgmode/orgmode.go
index 86222cc88..ddd445aba 100644
--- a/modules/markup/orgmode/orgmode.go
+++ b/modules/markup/orgmode/orgmode.go
@@ -8,6 +8,7 @@ import (
"bytes"
"fmt"
"html"
+ "strings"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
@@ -94,10 +95,23 @@ func (r *Renderer) WriteRegularLink(l org.RegularLink) {
}
switch l.Kind() {
case "image":
- r.WriteString(fmt.Sprintf(``, link, description, description))
+ imageSrc := getMediaURL(link)
+ fmt.Fprintf(r, ``, imageSrc, description, description)
case "video":
- r.WriteString(fmt.Sprintf(``, link, description, description))
+ videoSrc := getMediaURL(link)
+ fmt.Fprintf(r, ``, videoSrc, description, description)
default:
- r.WriteString(fmt.Sprintf(`%s`, link, description, description))
+ fmt.Fprintf(r, `%s`, link, description, description)
}
}
+
+func getMediaURL(l []byte) string {
+ srcURL := string(l)
+
+ // Check if link is valid
+ if len(srcURL) > 0 && !markup.IsLink(l) {
+ srcURL = strings.Replace(srcURL, "/src/", "/media/", 1)
+ }
+
+ return srcURL
+}