diff --git a/app/theme/twentyfifteen/twentyfifteen.go b/app/theme/twentyfifteen/twentyfifteen.go index 2dd146e..1bc669a 100644 --- a/app/theme/twentyfifteen/twentyfifteen.go +++ b/app/theme/twentyfifteen/twentyfifteen.go @@ -3,13 +3,11 @@ package twentyfifteen import ( "github.com/fthvgb1/wp-go/app/pkg/constraints" "github.com/fthvgb1/wp-go/app/pkg/constraints/widgets" - "github.com/fthvgb1/wp-go/app/pkg/models" "github.com/fthvgb1/wp-go/app/plugins" "github.com/fthvgb1/wp-go/app/theme/wp" "github.com/fthvgb1/wp-go/app/theme/wp/components" "github.com/fthvgb1/wp-go/app/theme/wp/middleware" "github.com/fthvgb1/wp-go/app/wpconfig" - "github.com/fthvgb1/wp-go/cache/reload" "strings" ) @@ -56,16 +54,10 @@ func setPaginationAndRender(h *wp.Handle) { func postThumb(h *wp.Handle) { d := h.GetDetailHandle() if d.Post.Thumbnail.Path != "" { - d.Post.Thumbnail = getPostThumbs(d.Post.Id, d.Post) + d.Post.Thumbnail = wpconfig.Thumbnail(d.Post.Thumbnail.OriginAttachmentData, "post-thumbnail", "") } } -var getPostThumbs = reload.BuildMapFn[uint64]("twentyFifteen-post-thumbnail", postThumbs) - -func postThumbs(post models.Posts) models.PostThumbnail { - return wpconfig.Thumbnail(post.Thumbnail.OriginAttachmentData, "post-thumbnail", "") -} - func renderCustomHeader(h *wp.Handle) { h.SetData("customHeader", customHeader(h)) } diff --git a/app/theme/twentyseventeen/twentyseventeen.go b/app/theme/twentyseventeen/twentyseventeen.go index 7705cd2..301034b 100644 --- a/app/theme/twentyseventeen/twentyseventeen.go +++ b/app/theme/twentyseventeen/twentyseventeen.go @@ -112,19 +112,13 @@ func errorsHandle(h *wp.Handle) { func postThumb(h *wp.Handle) { d := h.GetDetailHandle() if d.Post.Thumbnail.Path != "" { - d.Post.Thumbnail = getPostThumbs(d.Post.Id, d.Post) + img := wpconfig.Thumbnail(d.Post.Thumbnail.OriginAttachmentData, "full", "", "thumbnail", "post-thumbnail") + img.Sizes = "100vw" + img.Srcset = fmt.Sprintf("%s %dw, %s", img.Path, img.Width, img.Srcset) + d.Post.Thumbnail = img } } -var getPostThumbs = reload.BuildMapFn[uint64]("post-thumbnail", postThumbs) - -func postThumbs(post models.Posts) models.PostThumbnail { - img := wpconfig.Thumbnail(post.Thumbnail.OriginAttachmentData, "full", "", "thumbnail", "post-thumbnail") - img.Sizes = "100vw" - img.Srcset = fmt.Sprintf("%s %dw, %s", img.Path, img.Width, img.Srcset) - return img -} - var commentFormat = comment{} type comment struct { diff --git a/app/wpconfig/thememods.go b/app/wpconfig/thememods.go index 4994321..8065617 100644 --- a/app/wpconfig/thememods.go +++ b/app/wpconfig/thememods.go @@ -73,6 +73,7 @@ func Thumbnail(metadata models.WpAttachmentMetadata, Type, host string, except . up := strings.Split(metadata.File, "/") if metadata.File != "" && Type == "full" { mimeType := metadata.Sizes["thumbnail"].MimeType + metadata.Sizes = maps.Copy(metadata.Sizes) metadata.Sizes["full"] = models.MetaDataFileSize{ File: filepath.Base(metadata.File), Width: metadata.Width,