summaryrefslogtreecommitdiffhomepage
path: root/resources
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-07-30 08:53:50 +0200
committerBjørn Erik Pedersen <[email protected]>2019-07-30 08:53:50 +0200
commitc62bbf7b11d68d52ef11a4c6c70660914c473d08 (patch)
tree16788afdd6c001d087a7c4ea0bb1452b744c138b /resources
parent00a238e32c82b0651e4145e306840cffa46e535d (diff)
downloadhugo-c62bbf7b11d68d52ef11a4c6c70660914c473d08.tar.gz
hugo-c62bbf7b11d68d52ef11a4c6c70660914c473d08.zip
Fix image format detection for upper case extensions, e.g. JPG
This regression was introduced in 0.56.0. Fixes #6137
Diffstat (limited to 'resources')
-rw-r--r--resources/image_test.go10
-rw-r--r--resources/resource.go2
-rw-r--r--resources/testdata/sunrise.JPGbin0 -> 90587 bytes
3 files changed, 11 insertions, 1 deletions
diff --git a/resources/image_test.go b/resources/image_test.go
index 6639dbb24..061ae7710 100644
--- a/resources/image_test.go
+++ b/resources/image_test.go
@@ -152,6 +152,16 @@ func TestImageTransformLongFilename(t *testing.T) {
assert.Equal("/a/_hu59e56ffff1bc1d8d122b1403d34e039f_90587_c876768085288f41211f768147ba2647.jpg", resized.RelPermalink())
}
+// Issue 6137
+func TestImageTransformUppercaseExt(t *testing.T) {
+ assert := require.New(t)
+ image := fetchImage(assert, "sunrise.JPG")
+ resized, err := image.Resize("200x")
+ assert.NoError(err)
+ assert.NotNil(resized)
+ assert.Equal(200, resized.Width())
+}
+
// https://github.com/gohugoio/hugo/issues/5730
func TestImagePermalinkPublishOrder(t *testing.T) {
for _, checkOriginalFirst := range []bool{true, false} {
diff --git a/resources/resource.go b/resources/resource.go
index 236ba8ac6..0aee4a052 100644
--- a/resources/resource.go
+++ b/resources/resource.go
@@ -209,7 +209,7 @@ func (r *Spec) newResource(sourceFs afero.Fs, fd ResourceSourceDescriptor) (reso
fd.RelTargetFilename = sourceFilename
}
- ext := filepath.Ext(fd.RelTargetFilename)
+ ext := strings.ToLower(filepath.Ext(fd.RelTargetFilename))
mimeType, found := r.MediaTypes.GetFirstBySuffix(strings.TrimPrefix(ext, "."))
// TODO(bep) we need to handle these ambigous types better, but in this context
// we most likely want the application/xml type.
diff --git a/resources/testdata/sunrise.JPG b/resources/testdata/sunrise.JPG
new file mode 100644
index 000000000..7d7307bed
--- /dev/null
+++ b/resources/testdata/sunrise.JPG
Binary files differ