Now displaying book covers on the interface

This commit is contained in:
Mike Young
2019-11-17 13:21:35 -05:00
parent 9edc1f37c0
commit d55b2d4764
4 changed files with 18 additions and 5 deletions

View File

@@ -50,7 +50,9 @@ body{
}
.shelf{
grid-area: shelf;
margin: 0px auto 0px auto;
margin: 0px 0px;
padding: 0px;
list-style-type: none;
}
.shelf_contents{
display: flex;
@@ -67,3 +69,15 @@ body{
height: 50px;
width: 91px;
}
#book_shelf{
display: grid;
grid-template-columns: 25% 25% 25% 25%;
list-style-type: none;
}
.shelf_item{
}
.book_thumb{
width: 300px;
height: 375px;
}

View File

@@ -21,9 +21,9 @@
</div>
<div class="shelf">
<div class="shelf_contents" >
<ul>
<ul id="book_shelf">
{% for book in Books %}
<li>{{ book.title }} <img alt="Embedded Image" src="data:image;base64,{{ book.cover[2:-2]|bin_2_img }}" style="width:50px;height:50px;"/> </li>
<li class="shelf_item"><img alt="{{ book.title }}" src="data:image;base64,{{ book.cover | bin_2_img }}" class="book_thumb"/> </li>
{% endfor %}
</ul>
</div>

View File

@@ -7,4 +7,4 @@ register = template.Library()
@register.filter
def bin_2_img(_bin):
if _bin is not None: return b64encode(_bin)
if _bin is not None: return b64encode(_bin).decode('utf-8')