{"record":{"id":"61a85242a1f75194","repo":"gohugoio/hugo","slug":"invalid-image-dimensions","errorCode":null,"errorMessage":"invalid image dimensions","messagePattern":"invalid image dimensions","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":313,"sourceCode":"\t\t\t\tfirst := widthHeight[0]\n\t\t\t\tif first != \"\" {\n\t\t\t\t\tc.Width, err = strconv.Atoi(first)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn c, err\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif len(widthHeight) == 2 {\n\t\t\t\t\tsecond := widthHeight[1]\n\t\t\t\t\tif second != \"\" {\n\t\t\t\t\t\tc.Height, err = strconv.Atoi(second)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn c, err\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn c, errors.New(\"invalid image dimensions\")\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch c.Action {\n\tcase ActionCrop, ActionFill, ActionFit:\n\t\tif c.Width == 0 || c.Height == 0 {\n\t\t\treturn c, errors.New(\"must provide Width and Height\")\n\t\t}\n\tcase ActionResize:\n\t\tif c.Width == 0 && c.Height == 0 {\n\t\t\treturn c, errors.New(\"must provide Width or Height\")\n\t\t}\n\tdefault:\n\t\tif c.Width != 0 || c.Height != 0 {\n\t\t\treturn c, errors.New(\"width or height are not supported for this action\")\n\t\t}\n\t}","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L295-L331","documentation":"`DecodeImageConfig` parses a `WxH` dimension token by splitting on `x`. If splitting yields more than two parts (i.e. the token contains more than one `x`), the dimension spec is ambiguous and rejected as invalid at config.go:313.","triggerScenarios":"An image option string containing multiple `x` characters in a dimension token, e.g. `{{ $img.Resize \"100x200x50\" }}` or a value like `2x2x`.","commonSituations":"Accidental extra `x`; trying to express a third dimension or DPI; malformed copy-paste of a dimension string; a filename or unit leaking into the option string.","solutions":["Provide at most a single `WxH` pair, e.g. `100x200`.","Use `100x` (width only) or `x200` (height only) when you want one dimension.","Strip any stray characters/units from the option string."],"exampleFix":"{{/* before */}}\n{{ $img.Resize \"100x200x50\" }}\n\n{{/* after */}}\n{{ $img.Resize \"100x200\" }}","handlingStrategy":"validation","validationCode":"if strings.Count(dimToken, \"x\") > 1 { return errors.New(\"invalid image dimensions\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["A dimension token is WxH with at most one x.","Use 100x or x100 for single-dimension resize."],"tags":["hugo","image-processing","templates","validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}