diff options
author | Joe Mooring <[email protected]> | 2023-10-27 20:19:39 -0700 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-10-29 10:16:37 +0100 |
commit | 3ed28e4bfe2d333fdf1ca2434b57cfc10c3d9791 (patch) | |
tree | 165df55f1f5090b98423be2d8c1d7e78ad7bee41 /resources/images/color.go | |
parent | db14238ba323279b28e7ad4cfff5aa10909ccd18 (diff) | |
download | hugo-3ed28e4bfe2d333fdf1ca2434b57cfc10c3d9791.tar.gz hugo-3ed28e4bfe2d333fdf1ca2434b57cfc10c3d9791.zip |
resources/images: Create padding image filter
Closes #11599
Diffstat (limited to 'resources/images/color.go')
-rw-r--r-- | resources/images/color.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/resources/images/color.go b/resources/images/color.go index 0eedecb89..fe891fe88 100644 --- a/resources/images/color.go +++ b/resources/images/color.go @@ -56,13 +56,13 @@ func ColorToHexString(c color.Color) string { func hexStringToColor(s string) (color.Color, error) { s = strings.TrimPrefix(s, "#") - if len(s) != 3 && len(s) != 6 { + if len(s) != 3 && len(s) != 4 && len(s) != 6 && len(s) != 8 { return nil, fmt.Errorf("invalid color code: %q", s) } s = strings.ToLower(s) - if len(s) == 3 { + if len(s) == 3 || len(s) == 4 { var v string for _, r := range s { v += string(r) + string(r) @@ -80,7 +80,9 @@ func hexStringToColor(s string) (color.Color, error) { } // Set Alfa to white. - s += "ff" + if len(s) == 6 { + s += "ff" + } b, err := hex.DecodeString(s) if err != nil { |