add support for image descriptions
This commit is contained in:
parent
7ae5d8271c
commit
c3c4a84181
2 changed files with 14 additions and 0 deletions
|
@ -49,6 +49,7 @@ class ImageDirectory:
|
||||||
@dataclass
|
@dataclass
|
||||||
class ImagePath:
|
class ImagePath:
|
||||||
path: Path
|
path: Path
|
||||||
|
description: str = ""
|
||||||
|
|
||||||
def thumbnail_filename(self) -> str:
|
def thumbnail_filename(self) -> str:
|
||||||
return self.path.stem + ".thumb" + self.path.suffix
|
return self.path.stem + ".thumb" + self.path.suffix
|
||||||
|
@ -122,6 +123,13 @@ def find_images(root_path: Path) -> ImageDirectory:
|
||||||
# that separately
|
# that separately
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# If there's an associated .txt or .md file, read it in as the image's
|
||||||
|
# description
|
||||||
|
if file_path.with_suffix(".md").exists():
|
||||||
|
ip.description = markdown(file_path.with_suffix(".md").read_text())
|
||||||
|
elif file_path.with_suffix(".txt").exists():
|
||||||
|
ip.description = file_path.with_suffix(".txt").read_text()
|
||||||
|
|
||||||
image_dir.images.append(ip)
|
image_dir.images.append(ip)
|
||||||
|
|
||||||
if image_dir.cover_path is None and len(image_dir.images) > 0:
|
if image_dir.cover_path is None and len(image_dir.images) > 0:
|
||||||
|
|
|
@ -42,6 +42,12 @@
|
||||||
<img src="{{image_path.display_filename()}}" />
|
<img src="{{image_path.display_filename()}}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="photo-description">
|
||||||
|
{% if image_path.description %}
|
||||||
|
{{ image_path.description | safe }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="download">
|
<div id="download">
|
||||||
<a href="../{{image_path.path.name}}">view full size</a>
|
<a href="../{{image_path.path.name}}">view full size</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue