]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Remove disableDate and disableLatLong from MetaConfig
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 27 Jan 2026 17:46:52 +0000 (18:46 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 27 Jan 2026 20:47:32 +0000 (21:47 +0100)
Since the meta config is new (and exif config is deprecated), remove
these options from MetaConfig. The fields filter controls which metadata
is extracted, including Date and GPS fields.

The existing exif config options are preserved for backward compatibility.

Closes #14437

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
hugolib/config_test.go
resources/images/config.go
resources/images/image.go
resources/images/meta/meta.go
resources/images/meta/meta_integration_test.go

index 2273c6afd0286dc01804df080ecee52c83cbafc5..8af31a6329d82e22a34b786d04b1973181a857dc 100644 (file)
@@ -21,9 +21,9 @@ import (
 
        "github.com/bep/logg"
        "github.com/gohugoio/hugo/common/hmaps"
-       "github.com/gohugoio/hugo/htesting"
        "github.com/gohugoio/hugo/config"
        "github.com/gohugoio/hugo/config/allconfig"
+       "github.com/gohugoio/hugo/htesting"
 
        qt "github.com/frankban/quicktest"
        "github.com/spf13/afero"
index 42e07450dbb837d02d713c90e19ffe1d090dad82..c4e5f0c2976a52d4f36bfe88207abfb5d2cd841d 100644 (file)
@@ -573,14 +573,6 @@ type MetaConfig struct {
        // Use ["**"] to include all fields.
        Fields []string
 
-       // Hugo extracts the "photo taken" date/time into .Date by default.
-       // Set this to true to turn it off.
-       DisableDate bool
-
-       // Hugo extracts the "photo taken where" (GPS latitude and longitude) into
-       // .Long and .Lat. Set this to true to turn it off.
-       DisableLatLong bool
-
        // Which metadata sources to include.
        // Valid values are "exif", "iptc", "xmp".
        // Default is ["exif", "iptc"] (XMP is excluded for performance reasons).
index dfdae20c5fb177cc580cbba467602b12c1516265..80648f5f282da700436a7621117c82985965cba4 100644 (file)
@@ -139,8 +139,6 @@ func NewImageProcessor(warnl logg.LevelLogger, wasmDispatchers *warpc.Dispatcher
 
        m := cfg.Config.Imaging.Meta
        metaDecoder, err := meta.NewDecoder(
-               meta.WithDateDisabled(m.DisableDate),
-               meta.WithLatLongDisabled(m.DisableLatLong),
                meta.WithFields(m.Fields),
                meta.WithSources(m.Sources...),
                meta.WithWarnLogger(warnl),
index f76b5d74eba1c49713e54a1a6d8373f99bb1d743..54a71175541276d18d82c91af1a0528592dd0548 100644 (file)
@@ -313,15 +313,6 @@ func (d *Decoder) DecodeMeta(filename string, format imagemeta.ImageFormat, r io
        }
 
        shouldHandleTag := func(ti imagemeta.TagInfo) bool {
-               // Always include time and GPS tags (needed for Date, Lat, Long extraction).
-               // These may be in EXIF, XMP, or IPTC depending on the image.
-               if !d.noDate && isTimeTag(ti.Tag) {
-                       return true
-               }
-               if !d.noLatLong && isGPSTag(ti.Tag) {
-                       return true
-               }
-
                // For EXIF, only include tags from IFD0 (skip thumbnail data).
                if ti.Source == imagemeta.EXIF {
                        if !strings.HasPrefix(ti.Namespace, "IFD0") {
@@ -359,16 +350,8 @@ func (d *Decoder) DecodeMeta(filename string, format imagemeta.ImageFormat, r io
                return nil, err
        }
 
-       var tm time.Time
-       var lat, long float64
-
-       if !d.noDate {
-               tm, _ = tagInfos.GetDateTime()
-       }
-
-       if !d.noLatLong {
-               lat, long, _ = tagInfos.GetLatLong()
-       }
+       tm, _ := tagInfos.GetDateTime()
+       lat, long, _ := tagInfos.GetLatLong()
 
        exifTags := make(map[string]any)
        iptcTags := make(map[string]any)
index 4936faf5a91501545d5dddb51d3f7a9ee0cd5fcc..c44a186e1ef0db970ade730e658d86a0adafc0d2 100644 (file)
@@ -14,6 +14,7 @@ func TestMeta(t *testing.T) {
        files := `
 -- hugo.toml --
 [imaging.meta]
+fields = ['**']
 sources = ['exif', 'iptc', 'xmp']
 -- assets/sunset.jpg --
 sourcefilename: ../../testdata/sunset.jpg
@@ -87,8 +88,6 @@ func TestMetaConfig(t *testing.T) {
 -- hugo.toml --
 [imaging]
 [imaging.meta]
-disableDate = true
-disableLatLong = true
 fields = ['! *{Model,ColorSpace,Metering}*']
 sources = ['exif', 'iptc']
 -- assets/sunset.jpg --
@@ -110,11 +109,9 @@ XMPCity: {{ with .XMP.City }}{{ . }}{{ else }}NOT_IN_SOURCE{{ end }}
        b := hugolib.Test(t, files)
 
        b.AssertFileContent("public/index.html",
-               // disableLatLong = true
-               "Lat: 0",
-               "Long: 0",
-               // disableDate = true
-               "Date: 0001-01-01",
+               "Lat: 36.597441",
+               "Long: -4.50846",
+               "Date: 2017-10-27",
                // Exif is included
                "ExifMake: RICOH IMAGING COMPANY, LTD.",
                // Model is excluded by fields pattern '! *Model*'
@@ -126,6 +123,36 @@ XMPCity: {{ with .XMP.City }}{{ . }}{{ else }}NOT_IN_SOURCE{{ end }}
        )
 }
 
+func TestMetaFieldsFilterDateAndGPS(t *testing.T) {
+       t.Parallel()
+
+       files := `
+-- hugo.toml --
+[imaging.meta]
+fields = ['! GPS*', '! *Date*', '! *Time*']
+-- assets/sunset.jpg --
+sourcefilename: ../../testdata/sunset.jpg
+-- layouts/home.html --
+{{ $img := resources.Get "sunset.jpg" }}
+{{ $meta := $img.Meta }}
+{{ with $meta }}
+Lat: {{ .Lat }}
+Long: {{ .Long }}
+Date: {{ .Date.Format "2006-01-02" }}
+ExifMake: {{ .Exif.Make }}
+{{ end }}
+`
+
+       b := hugolib.Test(t, files)
+
+       b.AssertFileContent("public/index.html",
+               "Lat: 0",
+               "Long: 0",
+               "Date: 0001-01-01",
+               "ExifMake: RICOH IMAGING COMPANY, LTD.",
+       )
+}
+
 // TestMetaXMPOnly verifies behavior when only XMP is configured as a source.
 // Note: Date and Lat/Long are extracted from whichever configured source contains them.
 // The test image has GPS/Date in EXIF only, so with XMP-only sources they will be empty.