Skip to content

Commit

Permalink
Lazy loaded carousel items should have a src attribute
Browse files Browse the repository at this point in the history
A 1px by 1px base64 encoded thumbnail is used for covers that will
be lazy loaded as a placeholder. The data-src attribute points to the
real cover and is only added when necessary.

This resolves HTML validation issues on the home page.

Fixes: internetarchive#4481
  • Loading branch information
SaravgiYash authored and Sabreen-Parveen committed Feb 5, 2021
1 parent a56e7e7 commit 74c0de8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions openlibrary/templates/books/custom_carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
$ author_names = ''
$ modifier = ''
$ work_key = book.key if book.key.startswith('/work') else book.get('work_key')
$if lazy:
$ img_attr = 'data-lazy'
$else:
$ img_attr = 'src'

<div class="book carousel__item">
<div class="book-cover">
Expand All @@ -42,7 +38,11 @@
<img class="bookcover" loading="lazy"
width="130" height="200"
title="$('%s%s'%(title,byline))"
$img_attr="$(cover_url)"/>
$if lazy:
data-lazy="$(cover_url)"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="/>
$else:
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 74c0de8

Please sign in to comment.