X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/88f39c4f90a67164b2c3da7c7a41df420f3b17ab..f164694b5e7ad5ed5f6d95743f9259bd3a9292bd:/src/librarian/elements/figures/ilustr.py diff --git a/src/librarian/elements/figures/ilustr.py b/src/librarian/elements/figures/ilustr.py index 4e848ac..51bae4e 100644 --- a/src/librarian/elements/figures/ilustr.py +++ b/src/librarian/elements/figures/ilustr.py @@ -12,13 +12,36 @@ MAX_PNG_WEIGHT = 200000 class Ilustr(WLElement): - SHOULD_HAVE_ID = True + NUMBERING = 'i' EPUB_TAG = HTML_TAG = 'img' def get_html_attr(self, builder): - ## TODO: thumbnail. + cls = 'ilustr' + if self.attrib.get('wyrownanie'): + cls += ' ' + self.attrib['wyrownanie'] + if self.attrib.get('oblew'): + cls += ' oblew' + attr = { + 'class': cls, + 'alt': self.attrib.get('alt', ''), + 'title': self.attrib.get('alt', ''), + 'src': self.attrib.get('src', ''), + } + if self.attrib.get('srcset'): + attr['srcset'] = self.attrib['srcset'] + attr['sizes'] = ''' + (min-width: 718px) 600px, + (min-width: 600px) calc(100vw - 118px), + (min-width: 320px) calc(100vw - 75px), + (min-width: 15em) calc(100wv - 60px), + calc(100wv - 40px) + ''' + if self.attrib.get('szer'): + attr['style'] = 'width: ' + self.attrib['szer'] + return attr + def get_epub_attr(self, builder): url = urllib.parse.urljoin( builder.base_url, self.get('src') @@ -69,5 +92,3 @@ class Ilustr(WLElement): 'alt': self.attrib.get('alt', ''), 'title': self.attrib.get('alt', ''), } - - get_epub_attr = get_html_attr