Skip to content

Commit

Permalink
fix: blurry_image error without width (#77)
Browse files Browse the repository at this point in the history
* fix: blurry_image error without width

Fixes an error when using blurry_image without specifying a width

* docs: improve examples of blurry_image
  • Loading branch information
johnfraney committed Apr 28, 2024
1 parent 7f71e55 commit cad8abb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion blurry/plugins/jinja_plugins/blurry_image_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ class BlurryImage(StandaloneTag):
tags = {"blurry_image"}

def render(self, *args, **kwargs):
(image_url, width) = args
if len(args) == 2:
(image_url, width) = args
else:
image_url = args[0]
width = None

image_content_path: str = "." + urlparse(image_url).path
image_path = get_build_directory() / image_content_path

Expand Down
4 changes: 2 additions & 2 deletions docs/content/templates/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ It does a few things:
Basic example:

```jinja
{% blurry_image page.thumbnailUrl, alt="Image description" %}
{% blurry_image page.image, alt=page.name + " image" %}
```

Example with explicit width (image with this width must be present in the build folder):

```jinja
{% blurry_image page.thumbnailUrl, 250, id="image-id", class="responsive-image", loading="lazy" %}
{% blurry_image page.image, 250, alt=page.name + " image", id="image-id", class="responsive-image", loading="lazy" %}
```

0 comments on commit cad8abb

Please sign in to comment.