Hello,
I am using union to combine images from multiple folders but I would like to keep the control over priority of images how can achieve this.
My current code:
# in page front matter I define a folder where all the images are kept such as
---
imagesResources: "images/cars/**/*"
---
then I have this layout which takes all the images from images and the folder defined in the param and union them to use on the main page like this:
{{ $imagesResources := (union (resources.Match "images/all/*") (resources.Match (.Site.GetPage "/all").Params.imagesResources)) }}
{{ $sectionName := .Site.Params.folderName }}
{{ if not $sectionName }}
{{ $sectionName = "cars" }}
{{ end }}
{{ $imageResources := (union (resources.Match (printf "images/%s/*/*" $sectionName)) (resources.Match (.Site.GetPage (printf "/%s" $sectionName)).Params.imagesResources)) }}
{{ $count := 8 }}
{{ with .Params.noOfGalleryImages }}
{{ $count = . }}
{{ end }}
on the main page where I use the gallery I have the front matter
---
noOfGalleryImages: 12
preferedGallery:
- images/somefolder/image1.jpg
- images/somefolder/image2.jpg
---
what I am not able to work out is
- Use the preferred images first and then take images from other sources to match the count provided in the layout
- make sure the images are not duplicated.
the preferred images comes from the same source I just want to show them higher. currently I drop all images in different folders and dynamically generating galleries. This way I do not have to define 90 images in the page front matter.
Thank you!