thumbnail loading

This commit is contained in:
Christoph J. Scherr 2023-10-01 19:06:35 +02:00
parent c42653df80
commit 6ad7f0cfbd
7 changed files with 7 additions and 6 deletions

View File

@ -3,7 +3,6 @@ Title: Bash Arrays
Subtitle: sub
Desc: Brief intro to Bash Arrays
Date: 2023-09-29
Thumbnail: media/thumbnails/wayland.png
Keywords: bash
technology
Category: Test

View File

@ -3,6 +3,7 @@ Title: Bash Arrays
Subtitle: sub
Desc: Brief intro to Bash Arrays
Date: 2023-09-29
Thumbnail: img/thumbnails/bash.png
Keywords: bash
technology
Category: Test

View File

@ -54,7 +54,10 @@ class BlogPost(Searchable):
body_de = models.TextField(blank=True, default="")
category = models.ForeignKey(
Category, on_delete=models.SET_NULL, null=True)
thumbnail = models.ImageField(blank=True, upload_to="img/thumbnails")
thumbnail = models.ImageField(
blank=True,
upload_to="img/thumbnails",
default="img/thumbnails/default.jpg")
featured = models.BooleanField(default=False)
langs = models.CharField(
default="['en': False, 'de': False]", max_length=64)
@ -107,9 +110,9 @@ class BlogPost(Searchable):
self.date = meta_en["date"][0]
self.featured = meta_en["featured"][0] == "True"
self.public = meta_en["public"][0] == "True"
# self.thumbnail = meta_en["thumbnail"]
if "thumbnail" in meta_en:
self.thumbnail = meta_en["thumbnail"][0]
# TODO: parse keywords from markdown
# TODO: parse category from markdown
try:
category: Category = Category.objects.get(
@ -120,8 +123,6 @@ class BlogPost(Searchable):
logger.debug(f"category of {self}: {category}")
self.category = category
# if keyword or category do not exist, create them
# I suppose
except Exception as e:
logger.warning(
f"could not generate metadata {self.slug} from markdown: {e}")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB