From 6b99ab34eb77c64bd6772799ebfb727495b9d4fd Mon Sep 17 00:00:00 2001
From: Tetrakern <26898880+Tetrakern@users.noreply.github.com>
Date: Fri, 27 Jan 2023 12:09:47 +0100
Subject: [PATCH] Add fallback image to ePUBs
---
epubs/_build/templates/content.opf | 1 +
epubs/_build/templates/image_fallback.jpg | Bin 0 -> 1128 bytes
includes/functions/_epub.php | 5 +++++
3 files changed, 6 insertions(+)
create mode 100644 epubs/_build/templates/image_fallback.jpg
diff --git a/epubs/_build/templates/content.opf b/epubs/_build/templates/content.opf
index b9f5ead3..cf307c4c 100644
--- a/epubs/_build/templates/content.opf
+++ b/epubs/_build/templates/content.opf
@@ -18,6 +18,7 @@
+
diff --git a/epubs/_build/templates/image_fallback.jpg b/epubs/_build/templates/image_fallback.jpg
new file mode 100644
index 0000000000000000000000000000000000000000..2ee413e9e8821922d1b793e2aca199cb0f46ca3b
GIT binary patch
literal 1128
zcmex=b7B&_TU}I+k19m9j
z00T}C;D!T6kS=CsRv_Z$VB>&`6V3R4h(VBpA%)=tGoum%lOQ9rAmjfd4AKmY42-Nm
zmm&ZQD;qlpC)fX53>+XYFfe>U$U#{GKNI&&sSf+z9e4TwgUEj4+mf?PFP*$r*Hj+C
zz`$|I0bK*oA`ysL$TDCXm;{i87#QU7sAa~Y)<}SX5fqk;Y%J^$lYk)%^nxG*yAX$>
zp)jY2vXNttMDBvdCoN2+slQ{**nZ!b
zwe3g1%TT3Rs%OP+%=QjnqGs~tq>{0J@_eC7Q>Uf~-w=GhZ9%E%MpNH2}i=g
zZO3z)1Cq)oR@;LXPnx-L;R)|`22MNXc}gm?Z@<6&$?C$`
zxo$H#8>h!59#N6Id&=YZ@2fB0OnntvZMgki?(f3P?>=51LT@s7XBeAJJL?%dqj+A$
z^vG}_yB$GoYvNk1+85`w?#v3womCQ5yL+e5`}BMl&x})3dB2OiO8%An__Iy37nh6$
z&yTn3_E}lqd$*um=;;o#ck|_9wAS4Y%U$NZN#MHXXR({PEE+v3Ept{smALk}+Nhjw
zL+|0D>svC;?vA{j#mh9wY4Nt;h=!%&=L$c3{9`Y?t?+p`yOV9^J?Z^U>taMqOpXeD
zSbEL&oyZOyX9Hz}+gSw*m~~HjDn>rpFv%`(HFMs(*{iF{-YiaJaW{Ed{Pj6d*9wUv5fD<{ckUI+_k-Eww6h^Tc=iESJSG(
z*nShcjZJqd-l!gGWe}gq{cP%w^G`O;w|YP4^)>_R+T9rs=FH!>|NY1HuYbMV5pZkL
v&b1~jd!AYD5Mr9zf90qBMsNxjM9Ff%gqr}#4UE8aX%5N)I215L6x;*=g0qD#
literal 0
HcmV?d00001
diff --git a/includes/functions/_epub.php b/includes/functions/_epub.php
index 3ca7b477..516af0a8 100644
--- a/includes/functions/_epub.php
+++ b/includes/functions/_epub.php
@@ -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 );
}