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:
|
||||
|
||||
- pongo2-addons standardmäßig eingebunden
|
||||
- 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
|
||||
- `t=ZIEL_VERZEICHNIS` Parameter im `image_process` Filter
|
||||
|
@ -116,8 +116,9 @@ type ImagingConfig struct {
|
||||
Anchor string `yaml:"Anchor"`
|
||||
Quality int `yaml:"Quality"`
|
||||
|
||||
Filename string `yaml:"-"`
|
||||
Format string `yaml:"-"`
|
||||
TargetDir string `yaml:"-"`
|
||||
Filename string `yaml:"-"`
|
||||
Format string `yaml:"-"`
|
||||
}
|
||||
|
||||
// PathConfig of subdir
|
||||
|
@ -109,6 +109,8 @@ func parseImageParams(str string) (*config.ImagingConfig, error) {
|
||||
p.Height, err = strconv.Atoi(e[1])
|
||||
case "f":
|
||||
p.Filename = e[1]
|
||||
case "t":
|
||||
p.TargetDir = e[1]
|
||||
case "p":
|
||||
p.Process = e[1]
|
||||
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() {
|
||||
Log.Noticef("skipped processing image from %s to %s, file already exists", imgSource, imgTarget)
|
||||
|
@ -56,10 +56,10 @@
|
||||
{% for sl in Data.slider %}
|
||||
<div class="slide">
|
||||
<img
|
||||
src="{{ sl.img|image_process:"p=fill,w=1440,h=600,q=60" }}"
|
||||
srcset="{{ sl.img|image_process:"p=fill,w=768,h=384,q=60" }} 768w,
|
||||
{{ sl.img|image_process:"p=fill,w=1440,h=600,q=60" }} 1440w,
|
||||
{{ sl.img|image_process:"p=fill,w=1920,h=800,q=60" }} 1920w"
|
||||
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,t=/img" }} 768w,
|
||||
{{ 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,t=/img" }} 1920w"
|
||||
alt="{{ sl.alt }}" style="opacity:{{ sl.opacity|default:1 }}">
|
||||
</div>
|
||||
{% endfor %}
|
||||
@ -103,10 +103,10 @@
|
||||
<div class="maincontent">
|
||||
{% if Data.background %}
|
||||
<img
|
||||
src="{{ Data.background|image_process:"p=fill,w=1440,h=810,q=30" }}"
|
||||
srcset="{{ Data.background|image_process:"p=fill,w=768,h=768,q=30" }} 768w,
|
||||
{{ Data.background|image_process:"p=fill,w=1440,h=810,q=30" }} 1440w,
|
||||
{{ Data.background|image_process:"p=fill,w=1920,h=1020,q=30" }} 1920w"
|
||||
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,t=/img" }} 768w,
|
||||
{{ 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,t=/img" }} 1920w"
|
||||
alt="{{ Meta.Title }}" class="img2bg">
|
||||
{% endif %}
|
||||
<div class="white_section section_padding">
|
||||
|
Loading…
Reference in New Issue
Block a user