Add fallback image to ePUBs

This commit is contained in:
Tetrakern 2023-01-27 12:09:47 +01:00
parent 7fa390b9e3
commit 6b99ab34eb
3 changed files with 6 additions and 0 deletions

View File

@ -18,6 +18,7 @@
<item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml" />
<item href="Text/frontmatter.html" id="frontmatter" media-type="application/xhtml+xml" />
<item href="Text/toc.html" id="toc" media-type="application/xhtml+xml" />
<item href="Images/image_fallback.jpg" id="fictioneer_image_fallbackjpg" media-type="image/jpg"/>
</manifest>
<spine toc="ncx">

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -209,6 +209,9 @@ if ( ! function_exists( 'fictioneer_prepare_build_directory' ) ) {
fclose( $css_file );
}
// Copy fallback image
copy( $dir . '_build/templates/image_fallback.jpg', $epub_dir . '/OEBPS/Images/image_fallback.jpg' );
// Copy container XML
copy(
$dir . '_build/templates/container.xml',
@ -577,6 +580,7 @@ if ( ! function_exists( 'fictioneer_generate_epub_opf' ) ) {
$m_item->setAttribute( 'href', 'Images/cover' . $extension );
$m_item->setAttribute( 'id', 'cover' . $extension );
$m_item->setAttribute( 'media-type', 'image/' . substr( $extension, 1 ) );
$m_item->setAttribute( 'fallback', 'fictioneer_image_fallbackjpg' );
$manifest->appendChild( $m_item );
$m_item = $opf->createElement( 'item' );
@ -602,6 +606,7 @@ if ( ! function_exists( 'fictioneer_generate_epub_opf' ) ) {
$m_item->setAttribute( 'href', 'Images/' . $img[0] );
$m_item->setAttribute( 'id', $img[0] );
$m_item->setAttribute( 'media-type', 'image/' . $img[1] );
$m_item->setAttribute( 'fallback', 'fictioneer_image_fallbackjpg' );
$manifest->appendChild( $m_item );
}