mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-24 21:56:05 +02:00
resources: Fix 2 image file cache key issues
* Always include the content hash in the cache key for unprocessed images. * Always include the image config hash in the cache key. This is also a major cleanup/simplification of the implementation in this area. Note that this, unfortunately, forces new hashes/filenames for generated images. Fixes #13273 Fixes #13272
This commit is contained in:
@@ -217,7 +217,7 @@ func (p *ImageProcessor) FiltersFromConfig(src image.Image, conf ImageConfig) ([
|
||||
case "resize":
|
||||
filters = append(filters, gift.Resize(conf.Width, conf.Height, conf.Filter))
|
||||
case "crop":
|
||||
if conf.AnchorStr == smartCropIdentifier {
|
||||
if conf.Anchor == SmartCropAnchor {
|
||||
bounds, err := p.smartCrop(src, conf.Width, conf.Height, conf.Filter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -232,7 +232,7 @@ func (p *ImageProcessor) FiltersFromConfig(src image.Image, conf ImageConfig) ([
|
||||
filters = append(filters, gift.CropToSize(conf.Width, conf.Height, conf.Anchor))
|
||||
}
|
||||
case "fill":
|
||||
if conf.AnchorStr == smartCropIdentifier {
|
||||
if conf.Anchor == SmartCropAnchor {
|
||||
bounds, err := p.smartCrop(src, conf.Width, conf.Height, conf.Filter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -329,12 +329,12 @@ func (p *ImageProcessor) doFilter(src image.Image, targetFormat Format, filters
|
||||
return dst, nil
|
||||
}
|
||||
|
||||
func GetDefaultImageConfig(action string, defaults *config.ConfigNamespace[ImagingConfig, ImagingConfigInternal]) ImageConfig {
|
||||
func GetDefaultImageConfig(defaults *config.ConfigNamespace[ImagingConfig, ImagingConfigInternal]) ImageConfig {
|
||||
if defaults == nil {
|
||||
defaults = defaultImageConfig
|
||||
}
|
||||
return ImageConfig{
|
||||
Action: action,
|
||||
Anchor: -1, // The real values start at 0.
|
||||
Hint: defaults.Config.Hint,
|
||||
Quality: defaults.Config.Imaging.Quality,
|
||||
}
|
||||
|
Reference in New Issue
Block a user