performance: thumbnails are now forced to be saved in jpeg format
This commit is contained in:
parent
3fcf291e6d
commit
42646c601d
|
@ -294,6 +294,9 @@ func (post *Post) GetThumbnailTargetPath(cfg *config.Config) string {
|
|||
baseDownloadDir := cfg.String("download.directory")
|
||||
p := path.Join(baseDownloadDir, "_thumbnails", post.GetSubreddit(), post.GetImageFilename())
|
||||
abs, _ := filepath.Abs(p)
|
||||
if before, found := strings.CutSuffix(abs, ".png"); found {
|
||||
return before + ".jpeg"
|
||||
}
|
||||
return abs
|
||||
}
|
||||
|
||||
|
@ -305,7 +308,11 @@ func (post *Post) GetThumbnailTargetDir(cfg *config.Config) string {
|
|||
}
|
||||
|
||||
func (post *Post) GetThumbnailRelativePath() string {
|
||||
return path.Join("_thumbnails", post.GetSubreddit(), post.GetImageFilename())
|
||||
p := path.Join("_thumbnails", post.GetSubreddit(), post.GetImageFilename())
|
||||
if before, found := strings.CutSuffix(p, ".png"); found {
|
||||
return before + ".jpeg"
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (post *Post) GetImageRelativePath(device *models.Device) string {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package routes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
|
@ -32,6 +33,7 @@ func (routes *Routes) PageSubredditsDetails(rw http.ResponseWriter, r *http.Requ
|
|||
code, message := errs.HTTPMessage(err)
|
||||
rw.WriteHeader(code)
|
||||
data.Error = message
|
||||
fmt.Println(data)
|
||||
if err := detailsview.Detailsview(c, data).Render(ctx, rw); err != nil {
|
||||
log.New(ctx).Err(err).Error("failed to render subreddit details page")
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ templ ImageCard(data *models.Image, opts ImageCardOption) {
|
|||
class="object-contain max-w-[16rem] max-h-[16rem]"
|
||||
src={ fmt.Sprintf("/img/%s", data.ThumbnailRelativePath) }
|
||||
alt={ data.PostTitle }
|
||||
loading="lazy"
|
||||
/>
|
||||
</a>
|
||||
</figure>
|
||||
|
|
|
@ -17,7 +17,11 @@ type Data struct {
|
|||
|
||||
templ Detailsview(c *views.Context, data Data) {
|
||||
@components.Doctype() {
|
||||
if data.Subreddit != nil {
|
||||
@components.Head(c, components.HeadTitle(fmt.Sprintf("Subreddit - %s", data.Subreddit.Name)))
|
||||
} else {
|
||||
@components.Head(c, components.HeadTitle("Subreddit - 404 NOT FOUND"))
|
||||
}
|
||||
@components.Body(c) {
|
||||
@DetailsContent(c, data)
|
||||
@components.NotificationContainer()
|
||||
|
|
Loading…
Reference in a new issue