target dir via t parameter in image_process filter
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8210e16305
commit
6b34509d9a
15
RELEASE.md
15
RELEASE.md
@ -1,16 +1,3 @@
|
|||||||
NEUERUNGEN:
|
NEUERUNGEN:
|
||||||
|
|
||||||
- pongo2-addons standardmäßig eingebunden
|
- `t=ZIEL_VERZEICHNIS` Parameter im `image_process` Filter
|
||||||
- fnRequest Template-Funktion für Web-Requests
|
|
||||||
- fnRender Template-Funktion um Unterseiten zu rendern
|
|
||||||
- eigene Filter via Javascript
|
|
||||||
- image_process Template-Filter um Bilder zu skalieren (resize, fit, fill)
|
|
||||||
- json Template-Filter um Variablen als JSON auszugeben
|
|
||||||
- dump Template-Filter um Variablen über spew.Dump auszugeben
|
|
||||||
- Collections via Web-Request mit optionaler Unternavigation
|
|
||||||
- Timestamp Variable
|
|
||||||
|
|
||||||
BUG FIXES:
|
|
||||||
|
|
||||||
- CR in Markdown entfernt, blackfriday-Bug
|
|
||||||
- Pfadangaben gesäubert, da sonst bei `-out ./html` der Assets-Pfad falsch ermittelt wurde
|
|
||||||
|
@ -116,8 +116,9 @@ type ImagingConfig struct {
|
|||||||
Anchor string `yaml:"Anchor"`
|
Anchor string `yaml:"Anchor"`
|
||||||
Quality int `yaml:"Quality"`
|
Quality int `yaml:"Quality"`
|
||||||
|
|
||||||
Filename string `yaml:"-"`
|
TargetDir string `yaml:"-"`
|
||||||
Format string `yaml:"-"`
|
Filename string `yaml:"-"`
|
||||||
|
Format string `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathConfig of subdir
|
// PathConfig of subdir
|
||||||
|
@ -109,6 +109,8 @@ func parseImageParams(str string) (*config.ImagingConfig, error) {
|
|||||||
p.Height, err = strconv.Atoi(e[1])
|
p.Height, err = strconv.Atoi(e[1])
|
||||||
case "f":
|
case "f":
|
||||||
p.Filename = e[1]
|
p.Filename = e[1]
|
||||||
|
case "t":
|
||||||
|
p.TargetDir = e[1]
|
||||||
case "p":
|
case "p":
|
||||||
p.Process = e[1]
|
p.Process = e[1]
|
||||||
case "a":
|
case "a":
|
||||||
@ -207,7 +209,29 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imgTarget := ResolveOutputPath(p.Filename)
|
var imgTarget string
|
||||||
|
if p.TargetDir != "" {
|
||||||
|
imgTarget = ResolveOutputPath(
|
||||||
|
path.Clean(p.TargetDir) + "/" +
|
||||||
|
p.Filename,
|
||||||
|
)
|
||||||
|
|
||||||
|
pt := path.Dir(imgTarget)
|
||||||
|
if _, err := os.Stat(pt); os.IsNotExist(err) {
|
||||||
|
Log.Infof("create image target dir: %s", pt)
|
||||||
|
if err := os.MkdirAll(pt, 0755); err != nil {
|
||||||
|
return nil, &pongo2.Error{
|
||||||
|
Sender: "filter:image_resize",
|
||||||
|
OrigError: fmt.Errorf("could not create image target dir '%s': %s", pt, err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Filename = ResolveNavPath(p.TargetDir + "/" + p.Filename)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
imgTarget = ResolveOutputPath(p.Filename)
|
||||||
|
}
|
||||||
|
|
||||||
if f, err := os.Stat(imgTarget); err == nil && !f.IsDir() {
|
if f, err := os.Stat(imgTarget); err == nil && !f.IsDir() {
|
||||||
Log.Noticef("skipped processing image from %s to %s, file already exists", imgSource, imgTarget)
|
Log.Noticef("skipped processing image from %s to %s, file already exists", imgSource, imgTarget)
|
||||||
|
@ -56,10 +56,10 @@
|
|||||||
{% for sl in Data.slider %}
|
{% for sl in Data.slider %}
|
||||||
<div class="slide">
|
<div class="slide">
|
||||||
<img
|
<img
|
||||||
src="{{ sl.img|image_process:"p=fill,w=1440,h=600,q=60" }}"
|
src="{{ sl.img|image_process:"p=fill,w=1440,h=600,q=60,t=/img" }}"
|
||||||
srcset="{{ sl.img|image_process:"p=fill,w=768,h=384,q=60" }} 768w,
|
srcset="{{ sl.img|image_process:"p=fill,w=768,h=384,q=60,t=/img" }} 768w,
|
||||||
{{ sl.img|image_process:"p=fill,w=1440,h=600,q=60" }} 1440w,
|
{{ sl.img|image_process:"p=fill,w=1440,h=600,q=60,t=/img" }} 1440w,
|
||||||
{{ sl.img|image_process:"p=fill,w=1920,h=800,q=60" }} 1920w"
|
{{ sl.img|image_process:"p=fill,w=1920,h=800,q=60,t=/img" }} 1920w"
|
||||||
alt="{{ sl.alt }}" style="opacity:{{ sl.opacity|default:1 }}">
|
alt="{{ sl.alt }}" style="opacity:{{ sl.opacity|default:1 }}">
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -103,10 +103,10 @@
|
|||||||
<div class="maincontent">
|
<div class="maincontent">
|
||||||
{% if Data.background %}
|
{% if Data.background %}
|
||||||
<img
|
<img
|
||||||
src="{{ Data.background|image_process:"p=fill,w=1440,h=810,q=30" }}"
|
src="{{ Data.background|image_process:"p=fill,w=1440,h=810,q=30,t=/img" }}"
|
||||||
srcset="{{ Data.background|image_process:"p=fill,w=768,h=768,q=30" }} 768w,
|
srcset="{{ Data.background|image_process:"p=fill,w=768,h=768,q=30,t=/img" }} 768w,
|
||||||
{{ Data.background|image_process:"p=fill,w=1440,h=810,q=30" }} 1440w,
|
{{ Data.background|image_process:"p=fill,w=1440,h=810,q=30,t=/img" }} 1440w,
|
||||||
{{ Data.background|image_process:"p=fill,w=1920,h=1020,q=30" }} 1920w"
|
{{ Data.background|image_process:"p=fill,w=1920,h=1020,q=30,t=/img" }} 1920w"
|
||||||
alt="{{ Meta.Title }}" class="img2bg">
|
alt="{{ Meta.Title }}" class="img2bg">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="white_section section_padding">
|
<div class="white_section section_padding">
|
||||||
|
Loading…
Reference in New Issue
Block a user