diff --git a/cookbook/tables.py b/cookbook/tables.py index 68d89fb9b..1ee7b941d 100644 --- a/cookbook/tables.py +++ b/cookbook/tables.py @@ -5,22 +5,12 @@ from django_tables2.utils import A # alias for Accessor from .models import * -from django.utils.safestring import mark_safe -from django.templatetags.static import static -class ImageUrlColumn(tables.LinkColumn): +class ImageUrlColumn(tables.Column): def render(self, value): if value.url: - src = value.url - _class = '' - style = 'object-fit: cover;' - - else: - src = static("recipe_no_image.svg") - _class = 'd-none d-lg-block' - style = 'object-fit: inherit;' - - return mark_safe(f'{_(') + return value.url + return None class RecipeTableSmall(tables.Table): @@ -40,7 +30,7 @@ class RecipeTable(tables.Table): name = tables.LinkColumn('view_recipe', args=[A('id')]) all_tags = tables.Column( attrs={'td': {'class': 'd-none d-lg-table-cell'}, 'th': {'class': 'd-none d-lg-table-cell'}}) - image = ImageUrlColumn('view_recipe', args=[A('id')]) + image = ImageUrlColumn() class Meta: model = Recipe diff --git a/cookbook/templates/recipes_table.html b/cookbook/templates/recipes_table.html index 228a5018e..3c6854809 100644 --- a/cookbook/templates/recipes_table.html +++ b/cookbook/templates/recipes_table.html @@ -14,7 +14,18 @@