EPUBCheck MED_007: picture source without type
Updated:
EPUBCheck MED_007 is an error message: “Picture "source" elements must define a "type" attribute when they reference foreign resources; found resource "…" of type "…".” A source element inside picture references a foreign resource without a type attribute. A reading app uses the type to skip formats it cannot show, so a non-core image format must say what it is; EPUBCheck names the file and its type.
The official message
Picture "source" elements must define a "type" attribute when they reference foreign resources; found resource "%1$s" of type "%2$s".
- Default severity
- Error. The EPUB breaks a rule of the specification and is invalid. Stores and Send to Kindle may reject it, and EPUBCheck exits with status 1.
- EPUBCheck version
- 5.4.0
EPUBCheck prints this ID with an underscore instead of a hyphen; this page uses the ID exactly as EPUBCheck reports it.
%1$s, %2$s… are filled in with the file, value or element EPUBCheck found.
Typical causes
- A picture element written for the web, where source elements often omit type.
- AVIF, JPEG XL or other newer formats offered without a type attribute.
How to fix it
- Add the media type to the source element, for example
<source srcset="fig1.avif" type="image/avif"/>. - Keep a core format (JPEG, PNG, GIF, WebP or SVG) in the img element of the same picture as the fallback.
- Rebuild the EPUB and run EPUBCheck again to confirm the message is gone.
When it's not this
If the img itself uses a non-core format, the error is MED-003.
Terms used here
Other MED messages
MED-008The time specified in the clipBegin attribute must not be after clipEnd.MED-005Media Overlay audio reference … to non-standard audio type … found.MED-009The time specified in the clipBegin attribute must not be the same as clipEnd.MED-004Image file header may be corrupted.MED_010EPUB Content Documents referenced from a Media Overlay must specify the "media-overlay" attribute.MED-003Picture "img" elements must reference core media type resources, but found resource "…" of type "…".
Sources
Message text and severity from EPUBCheck 5.4.0 (W3C, BSD-3-Clause). Explanation by EpubCC.