2023-02-16 06:36:43 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/fthvgb1/wp-go/helper/slice"
|
|
|
|
"github.com/fthvgb1/wp-go/internal/pkg/cache"
|
|
|
|
"github.com/fthvgb1/wp-go/internal/pkg/logs"
|
|
|
|
"github.com/fthvgb1/wp-go/internal/pkg/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (h *Handle) DisplayHeaderText() bool {
|
2023-02-28 15:38:23 +00:00
|
|
|
return h.themeMods.ThemeSupport.CustomHeader.HeaderText && "blank" != h.themeMods.HeaderTextcolor
|
2023-02-16 06:36:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handle) GetCustomHeader() (r models.PostThumbnail, isRand bool) {
|
2023-02-28 15:38:23 +00:00
|
|
|
hs, err := cache.GetHeaderImages(h.C, h.theme)
|
2023-02-16 06:36:43 +00:00
|
|
|
if err != nil {
|
|
|
|
logs.ErrPrintln(err, "获取页眉背景图失败")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if len(hs) < 1 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if len(hs) > 1 {
|
|
|
|
isRand = true
|
|
|
|
}
|
|
|
|
r, _ = slice.RandPop(&hs)
|
|
|
|
return
|
|
|
|
}
|