Add path parameter to image generation

This commit is contained in:
Christoph Hagen
2022-09-18 16:47:13 +02:00
parent 763b90f689
commit 3872a3e419
5 changed files with 15 additions and 3 deletions

View File

@ -109,11 +109,19 @@ struct PageContentGenerator {
private func handleImage(page: Element, file: String, rightTitle: String?, leftTitle: String?) -> String {
let imagePath = page.pathRelativeToRootForContainedInputFile(file)
let size = files.requireImage(source: imagePath, destination: imagePath, width: configuration.pageImageWidth)
let size = files.requireImage(
source: imagePath,
destination: imagePath,
requiredBy: page.path,
width: configuration.pageImageWidth)
let imagePath2x = imagePath.insert("@2x", beforeLast: ".")
let file2x = file.insert("@2x", beforeLast: ".")
files.requireImage(source: imagePath, destination: imagePath2x, width: 2 * configuration.pageImageWidth)
files.requireImage(
source: imagePath,
destination: imagePath2x,
requiredBy: page.path,
width: 2 * configuration.pageImageWidth)
let content: [PageImageTemplate.Key : String] = [
.image: file,

View File

@ -27,6 +27,7 @@ struct PageHeadGenerator {
files.requireImage(
source: sourceImagePath,
destination: destinationImagePath,
requiredBy: page.path,
width: PageHeadGenerator.linkPreviewDesiredImageWidth)
content[.image] = factory.html.linkPreviewImage(file: linkPreviewImageName)
}

View File

@ -53,6 +53,7 @@ struct SiteGenerator {
files.requireImage(
source: $0.sourcePath,
destination: $0.destinationPath,
requiredBy: element.path,
width: $0.desiredWidth,
desiredHeight: $0.desiredHeight)
}

View File

@ -39,6 +39,7 @@ struct ThumbnailListGenerator {
files.requireImage(
source: fullThumbnailPath,
destination: fullThumbnailPath,
requiredBy: item.path,
width: style.width,
desiredHeight: style.height)
@ -46,6 +47,7 @@ struct ThumbnailListGenerator {
files.requireImage(
source: fullThumbnailPath,
destination: fullThumbnailPath.insert("@2x", beforeLast: "."),
requiredBy: item.path,
width: style.width * 2,
desiredHeight: style.height * 2)