diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index 8bb3f610ba..bfde49b4e4 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -1224,6 +1224,15 @@ class OPF: # {{{ mt = item.get('media-type', '') if mt and 'xml' not in mt and 'html' not in mt: return item.get('href', None) + # OMF files have the cover as the first item in the spine + first_ref = self.first_spine_item() + if first_ref: + for item in self.itermanifest(): + if item.get('href') == first_ref: + mt = item.get('media-type', '') + if mt and mt.lower() in {'image/jpeg', 'image/jpg', 'image/png', 'image/webp'}: + return first_ref + break @property def raster_cover(self):