use epubimage format instead of global params

This commit is contained in:
Celogeek 2025-02-16 12:49:08 +01:00
parent a5ef2a2927
commit 87a127d04a
Signed by: celogeek
GPG Key ID: 850295F3747870DD
3 changed files with 6 additions and 5 deletions

View File

@ -73,6 +73,11 @@ func (i EPUBImage) EPUBImgPath() string {
return "OEBPS/" + i.ImgPath()
}
// MediaType of the epub image
func (i EPUBImage) MediaType() string {
return "image/" + i.Format
}
// ImgStyle style to apply to the image.
//
// center by default.

View File

@ -144,7 +144,7 @@ func (o Content) getManifest() []tag {
var imageTags, pageTags, spaceTags []tag
addTag := func(img epubimage.EPUBImage, withSpace bool) {
imageTags = append(imageTags,
tag{"item", tagAttrs{"id": img.ImgKey(), "href": img.ImgPath(), "media-type": o.ImageOptions.MediaType()}, ""},
tag{"item", tagAttrs{"id": img.ImgKey(), "href": img.ImgPath(), "media-type": img.MediaType()}, ""},
)
pageTags = append(pageTags,
tag{"item", tagAttrs{"id": img.PageKey(), "href": img.PagePath(), "media-type": "application/xhtml+xml"}, ""},

View File

@ -20,7 +20,3 @@ type Image struct {
Format string `yaml:"format" json:"format"`
AppleBookCompatibility bool `yaml:"apple_book_compatibility" json:"apple_book_compatibility"`
}
func (i Image) MediaType() string {
return "image/" + i.Format
}