Skip to content

Commit

Permalink
Resize blog post thumbnails to fit content size
Browse files Browse the repository at this point in the history
  • Loading branch information
lordiii committed Mar 24, 2024
1 parent 82e08e4 commit a9d83fd
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
/content/images/ifs/all/*
!/content/images/ifs/all/_index*

/static/media/img/ifs
/static/processed_images
10 changes: 3 additions & 7 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ not_found = "Inhalt nicht gefunden"
locale_name = "de_DE"
publish_time = "veröffentlicht am %date% um %time% Uhr von %author%"
all = "Alle"
status_finished = "Abgeschlossen"
status_active = "In Betrieb"
status_in_progress = "In Arbeit"
status_obsolete = "Ersetzt"
status_disabled = "Außer Betrieb"
status_broken = "Kaputt"
images = "Bilder"

[extra]
ifs_base_path = "https://www.mainframe.io/media/ifs-images"
Expand Down Expand Up @@ -81,7 +76,8 @@ not_found_content = "This is not the content you are looking for!"
not_found = "Content not found"
locale_name = "en_US"
publish_time = "published on %date% at %time% by %author%"
all="All"
all = "All"
images = "Images"

status_finished = "Finished"
status_in_progress = "In Progress"
Binary file modified static/media/blog/2012/lauflicht/img1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/media/blog/2013/30C3/thumbnail.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions templates/ifs/ifs-single.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ <h4 class="d-flex justify-content-between">

{% if page.lower %}
<a class="btn btn-sm my-auto btn-secondary h-100" href="{{ page.lower.path }}">
<<
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-bar-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M12.5 15a.5.5 0 0 1-.5-.5v-13a.5.5 0 0 1 1 0v13a.5.5 0 0 1-.5.5M10 8a.5.5 0 0 1-.5.5H3.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L3.707 7.5H9.5a.5.5 0 0 1 .5.5"/>
</svg>
</a>
{% endif %}

Expand All @@ -40,7 +42,9 @@ <h4 class="d-flex justify-content-between">

{% if page.higher %}
<a class="btn btn-sm my-auto btn-secondary h-100" href="{{ page.higher.path }}">
>>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-bar-right" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M6 8a.5.5 0 0 0 .5.5h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L12.293 7.5H6.5A.5.5 0 0 0 6 8m-2.5 7a.5.5 0 0 1-.5-.5v-13a.5.5 0 0 1 1 0v13a.5.5 0 0 1-.5.5"/>
</svg>
</a>
{% endif %}

Expand Down
14 changes: 8 additions & 6 deletions templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,16 @@
{% set page_description = blog_page.description | default(value="") %}

{% if blog_page.extra.thumbnail %}

{% set thumbnail_url = config.extra.resource_base ~ blog_page.extra.thumbnail %}
{% set thumbnail_metadata = get_image_metadata(path=blog_page.extra.thumbnail) %}

{% set thumbnail_path = blog_page.extra.thumbnail %}
{% set thumbnail_url = config.extra.resource_base ~ thumbnail_path %}
{% else %}
{% set thumbnail_url = "/media/img/logo-ktt.png" %}
{% set thumbnail_metadata = get_image_metadata(path=thumbnail_url) %}
{% set thumbnail_path = "/media/img/logo-ktt.png" %}
{% set thumbnail_url = thumbnail_path %}
{% endif %}

{% if thumbnail_url is not ending_with(".svg") %}
{% set resized_image = resize_image(path=thumbnail_path, format="auto", op="fit_height", width=150, height=150) %}
{% set thumbnail_url = resized_image.url %}
{% endif %}

{{
Expand Down

0 comments on commit a9d83fd

Please sign in to comment.