mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-10 17:22:38 +00:00
parent
2aa4c009ee
commit
196da49c9d
1 changed files with 12 additions and 1 deletions
|
@ -450,9 +450,20 @@ func (i *Image) encodeToDestinations(img image.Image, conf imageConfig, resource
|
||||||
target := filepath.Join(i.absPublishDir, filename)
|
target := filepath.Join(i.absPublishDir, filename)
|
||||||
|
|
||||||
file1, err := i.spec.Fs.Destination.Create(target)
|
file1, err := i.spec.Fs.Destination.Create(target)
|
||||||
|
if err != nil && os.IsNotExist(err) {
|
||||||
|
// When called from shortcodes, the target directory may not exist yet.
|
||||||
|
// See https://github.com/gohugoio/hugo/issues/4202
|
||||||
|
if err = i.spec.Fs.Destination.MkdirAll(filepath.Dir(target), os.FileMode(0755)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
file1, err = i.spec.Fs.Destination.Create(target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
} else if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
defer file1.Close()
|
defer file1.Close()
|
||||||
|
|
||||||
var w io.Writer
|
var w io.Writer
|
||||||
|
|
Loading…
Reference in a new issue