aboutsummaryrefslogtreecommitdiffhomepage
path: root/resources/image.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-09-14 17:19:30 +0200
committerBjørn Erik Pedersen <[email protected]>2020-09-15 07:54:24 +0200
commitcd00f7f9661d67951ef16c5198541f09f1c058b4 (patch)
treee47f1d30fbd9a60fa806e23e6f1e99ada5c7605e /resources/image.go
parent214afe4c1bb9c37bc6159e659d66ba9a268a2849 (diff)
downloadhugo-cd00f7f9661d67951ef16c5198541f09f1c058b4.tar.gz
hugo-cd00f7f9661d67951ef16c5198541f09f1c058b4.zip
resources/image: Fix nilpointer for images with no Exif
E.g. PNG files. Fixes #7688
Diffstat (limited to 'resources/image.go')
-rw-r--r--resources/image.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/resources/image.go b/resources/image.go
index d1d9f650d..e999c5d96 100644
--- a/resources/image.go
+++ b/resources/image.go
@@ -71,11 +71,11 @@ type imageMeta struct {
Exif *exif.Exif
}
-func (i *imageResource) Exif() (*exif.Exif, error) {
+func (i *imageResource) Exif() *exif.Exif {
return i.root.getExif()
}
-func (i *imageResource) getExif() (*exif.Exif, error) {
+func (i *imageResource) getExif() *exif.Exif {
i.metaInit.Do(func() {
@@ -131,10 +131,14 @@ func (i *imageResource) getExif() (*exif.Exif, error) {
})
if i.metaInitErr != nil {
- return nil, i.metaInitErr
+ panic(fmt.Sprintf("metadata init failed: %s", i.metaInitErr))
}
- return i.meta.Exif, nil
+ if i.meta == nil {
+ return nil
+ }
+
+ return i.meta.Exif
}
func (i *imageResource) Clone() resource.Resource {