Skip to content

Commit

Permalink
Added nested if else for lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
SaravgiYash committed Jan 27, 2021
1 parent 310a0b2 commit 6ccc59a
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions openlibrary/templates/books/custom_carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,22 @@
$ author_names = ''
$ modifier = ''
$ work_key = book.key if book.key.startswith('/work') else book.get('work_key')
$if lazy:
$ img_attr = 'data-lazy'
$ data_url = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
$ src_attr = 'src'
$else:
$ data_url = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
$ src_attr = 'data-src'
$ img_attr = 'src'

<div class="book carousel__item">
<div class="book-cover">
<a href="$(url)">
$if cover_url:
<img class="bookcover" loading="lazy"
width="130" height="200"
title="$('%s%s'%(title,byline))"
$src_attr="$(data_url)"
$img_attr="$(cover_url)"/>
$if lazy:
<img class="bookcover" loading="lazy"
width="130" height="200"
title="$('%s%s'%(title,byline))"
data-lazy="$(cover_url)"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="/>
$else:
<img class="bookcover" loading="lazy"
width="130" height="200"
title="$('%s%s'%(title,byline))"
src="$(cover_url)"/>
$else:
<div class="carousel__item__blankcover">
<div class="carousel__item__blankcover--title">$:macros.TruncateString(title, 70)</div>
Expand Down

0 comments on commit 6ccc59a

Please sign in to comment.