MCPcopy Index your code
hub / github.com/TruthHun/BookStack / ShowImg

Function ShowImg

utils/util.go:597–614  ·  view source on GitHub ↗

操作图片显示 如果用的是oss存储,这style是avatar、cover可选项

(img string, style ...string)

Source from the content-addressed store, hash-verified

595// 操作图片显示
596// 如果用的是oss存储,这style是avatar、cover可选项
597func ShowImg(img string, style ...string) (url string) {
598 img = strings.ReplaceAll(img, "\\", "/")
599 if strings.HasPrefix(img, "https://") || strings.HasPrefix(img, "http://") {
600 return img
601 }
602 img = "/" + strings.TrimLeft(img, "./")
603 switch StoreType {
604 case StoreOss:
605 s := ""
606 if len(style) > 0 && strings.TrimSpace(style[0]) != "" {
607 s = "/" + style[0]
608 }
609 url = strings.TrimRight(beego.AppConfig.String("oss::Domain"), "/ ") + img + s
610 case StoreLocal:
611 url = img
612 }
613 return
614}
615
616// Substr returns the substr from start to length.
617func Substr(s string, length int) string {

Callers 15

IndexMethod · 0.92
UsersMethod · 0.92
CategoryMethod · 0.92
UpdateCateIconMethod · 0.92
loginMethod · 0.92
getFansOrFollowMethod · 0.92
UserInfoMethod · 0.92
UserReleaseBookMethod · 0.92
SearchBookMethod · 0.92
BookInfoMethod · 0.92
BookListsMethod · 0.92
BookListsByCidsMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected