Skip to content

Commit

Permalink
img/imghover shortcodes optional width/height
Browse files Browse the repository at this point in the history
  • Loading branch information
Jieiku committed Jul 28, 2022
1 parent fe718cf commit 0e57376
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions templates/shortcodes/img.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@

{%- endif %}

{%- if not w or not h %}
{%- set metafile = page.path ~ path ~ src %}
{%- set meta = get_image_metadata(path=metafile) %}
{%- set w = meta.width %}
{%- set h = meta.height %}
{%- endif %}

{%- set img = src | split(pat="/") | last %}
{%- set name = img | split(pat=".") | first %}
<img src="{{ path | safe }}{{ img | safe }}"{% if class %} class="{{class}}"{% endif %}{% if alt %} alt="{{alt}}"{% endif %}{% if w %} width="{{w}}"{% endif %}{% if h %} height="{{h}}"{% endif %} />
5 changes: 3 additions & 2 deletions templates/shortcodes/imghover.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@
{%- set metafile = page.path ~ path ~ sourcepath %}
{%- set meta = get_image_metadata(path=metafile) %}
{%- set padding = meta.height / meta.width * p %}
/* height={{meta.height}} width={{meta.width}} (THIS IS BACKWARDS!?) */
{%- else %}
{%- set padding = 50 %}
{%- set metafile = page.path ~ path ~ sourcepath %}
{%- set meta = get_image_metadata(path=metafile) %}
{%- set padding = meta.height / meta.width * 50 %}
{%- endif %}


Expand Down
2 changes: 1 addition & 1 deletion theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "abridge"
description = "A fast and lightweight Zola theme using semantic html, a class-light abridge.css, and No JS."
license = "MIT"
homepage = "https://github.com/jieiku/abridge/"
min_version = "0.14.1"
min_version = "0.16.0"
demo = "https://abridge.netlify.app/"

[extra]
Expand Down

0 comments on commit 0e57376

Please sign in to comment.