Skip to content

Commit

Permalink
Merge pull request bmaupin#38 from bmaupin/gonejack-fix/thumbnail
Browse files Browse the repository at this point in the history
Fix missing thumbnail on MacOS

Closes bmaupin#18, closes bmaupin#20
  • Loading branch information
bmaupin authored Jun 15, 2021
2 parents 92396b2 + 6f8543c commit aee3936
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions epub.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ func (e *Epub) SetCover(internalImagePath string, internalCSSPath string) {
}

e.cover.imageFilename = filepath.Base(internalImagePath)
e.pkg.setCover(e.cover.imageFilename)

// Use default cover stylesheet if one isn't provided
if internalCSSPath == "" {
Expand Down
14 changes: 13 additions & 1 deletion pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
type pkg struct {
xml *pkgRoot
authorMeta *pkgMeta
coverMeta *pkgMeta
modifiedMeta *pkgMeta
}

Expand Down Expand Up @@ -94,10 +95,12 @@ type pkgItemref struct {
// <meta property="dcterms:modified">2011-01-01T12:00:00Z</meta>
type pkgMeta struct {
Refines string `xml:"refines,attr,omitempty"`
Property string `xml:"property,attr"`
Property string `xml:"property,attr,omitempty"`
Scheme string `xml:"scheme,attr,omitempty"`
ID string `xml:"id,attr,omitempty"`
Data string `xml:",chardata"`
Name string `xml:"name,attr,omitempty"`
Content string `xml:"content,attr,omitempty"`
}

// The <metadata> element
Expand Down Expand Up @@ -182,6 +185,15 @@ func (p *pkg) setAuthor(author string) {
p.xml.Metadata.Meta = updateMeta(p.xml.Metadata.Meta, p.authorMeta)
}

// Add an EPUB 2 cover meta element for backward compatibility (http://idpf.org/forum/topic-715)
func (p *pkg) setCover(coverRef string) {
p.coverMeta = &pkgMeta{
Name: "cover",
Content: coverRef,
}
p.xml.Metadata.Meta = updateMeta(p.xml.Metadata.Meta, p.coverMeta)
}

func (p *pkg) setIdentifier(identifier string) {
p.xml.Metadata.Identifier.Data = identifier
}
Expand Down

0 comments on commit aee3936

Please sign in to comment.