mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
resources/images: Require width and height for Crop, Fill, and Fit
Closes #9696
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
b80853de90
commit
cad2d8cc70
@@ -253,8 +253,17 @@ func DecodeImageConfig(action, config string, defaults ImagingConfig, sourceForm
|
||||
}
|
||||
}
|
||||
|
||||
if c.Width == 0 && c.Height == 0 {
|
||||
return c, errors.New("must provide Width or Height")
|
||||
switch c.Action {
|
||||
case "crop", "fill", "fit":
|
||||
if c.Width == 0 || c.Height == 0 {
|
||||
return c, errors.New("must provide Width and Height")
|
||||
}
|
||||
case "resize":
|
||||
if c.Width == 0 && c.Height == 0 {
|
||||
return c, errors.New("must provide Width or Height")
|
||||
}
|
||||
default:
|
||||
return c, errors.Errorf("BUG: unknown action %q encountered while decoding image configuration", c.Action)
|
||||
}
|
||||
|
||||
if c.FilterStr == "" {
|
||||
|
Reference in New Issue
Block a user