diff options
| author | Marat Radchenko <marat@slonopotamus.org> | 2020-07-26 16:19:02 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-26 16:19:02 +0300 |
| commit | f4dfbca5dc1ddbedda136252184c0eb1294fb129 (patch) | |
| tree | f8f4d9eec84d8150fb472bf3ff7c1c66e0aeeaf1 /lib | |
| parent | 3697bd99a66293867edbc37cf6c2fbebf143893d (diff) | |
resolves #353 gracefully handle invalid `:front-cover-image:` value (#354)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/asciidoctor-epub3/converter.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/asciidoctor-epub3/converter.rb b/lib/asciidoctor-epub3/converter.rb index e4eadea..23fb1c8 100644 --- a/lib/asciidoctor-epub3/converter.rb +++ b/lib/asciidoctor-epub3/converter.rb @@ -1349,19 +1349,19 @@ document.addEventListener('DOMContentLoaded', function(event, reader) { workdir = doc.attr 'docdir' workdir = '.' if workdir.nil_or_empty? - unless ::File.readable? ::File.join(workdir, image_path) - logger.error %(#{::File.basename doc.attr('docfile')}: front cover image not found or readable: #{::File.expand_path image_path, workdir}) + begin + @book.add_item(image_href, content: File.join(workdir, image_path)).cover_image + rescue => e + logger.error %(#{::File.basename doc.attr('docfile')}: error adding front cover image. Make sure that :front-cover-image: attribute points to a valid image file. #{e}) return nil end + return nil if @format == :kf8 + unless !image_attrs.empty? && (width = image_attrs['width']) && (height = image_attrs['height']) width, height = 1050, 1600 end - @book.add_item(image_href, content: File.join(workdir, image_path)).cover_image - - return nil if @format == :kf8 - # NOTE SVG wrapper maintains aspect ratio and confines image to view box content = %(<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en"> |
