Shortcode and Fallbacks

Hello, I’ve been experimenting new export files and can’t seem to figure out how to get fallbacks for media placed with the [audio] and [video] shortcode to work in ePub and ePub 3.0. As an example, this test page - - has fuctioning fallbacks for the H5P object and iFrame (Youtube video), but not the embedded video or audio files.

All of the fallbacks work fine in the PDF file. This only seems to be happening with ePubs. The error code I’m getting is:

_ERROR(MED-002): /var/www/osu/wordpress/wp-content/uploads/sites/89/pressbooks/exports/Test-Book-1521479769.3.epub/OEBPS/chapter-001-chapter-1.xhtml(43,11): Audio element doesn’t provide fallback.

Is this something I am doing wrong and need to rectify or something that needs fixed in the export script?

Screenshot of the ePub chapter in Apple iBooks:

This is a message from the epub validator saying it’s missing fallback text.

As seen in your screenshot, and in contrast to Epub2, Epub3 supports audio and video.

The player controls appear because audio and video files are supposed to be in the Epub3.

The code we generate for Audio and Video looks something like:

$output = "<video class='wp-video-shortcode' controls='controls'><source type='{$type}' src='{$src}' /><a href='{$src}'>{$src}</a></video>";

The fallback text is: <a href='{$src}'>{$src}</a>

Where src is supposed to be a link to something.

Does the media play when you press the play button on the controls? Unzip the epub and look for the files, are they in the Epub3?

It would be great if you could attach an example file of the Epub3 with only that chapter exported.

I generated some new files and noticed that the epub2 does actually include the fallbacks. Perhaps I accidentally opened the epub3 file twice earlier. The media placeholders in the epub3 do not play anything and the files are not there when I unzip the epub, so the issue actually seems to be that the files that should be embedded are not being bundled during export.

Current ePub can be downloaded here:

The book is only one chapter that I use for testing.

Can you paste the [audio] and [video] shortcodes you are using?

No problem. Here they are. I double-checked to make sure they were the default and I didn’t add anything:

[video width="1920" height="1080" mp4=""][/video]

[audio wav=""][/audio]

[audio m4a=""][/audio]

The only thing that jumped out to me when I was attempting to re-embed was the Attachment Display Settings dropdown, which is set to embed for all of these. Don’t know if that would make any difference.

Looks like its a bug.

We’re looking for src.

We should also look for 'mp3', 'm4a', 'ogg', 'wav', 'wma' (for audio) and 'mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv' (for video)

Workaround for Epub3 is to change your shortcodes to use SRC instead:

[video width="1920" height="1080" src=""][/video]

[audio src=""][/audio]

[audio src=""][/audio]


That does the trick. 17.5mb epub3 file instead of 3.0mb w/ all of the included media. Thanks!

1 Like

Thanks for troubleshooting this, @dac.chartrand! @shiflet.16 There’s now a ticket for this: