diff --git a/pelicanconf.py b/pelicanconf.py index 17e444f..e3e5a2f 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -110,7 +110,8 @@ JINJA_FILTERS = { "category_find": filters.category_find, "limit": filters.limit, "get_title": filters.get_title, - "get_html_title": filters.get_html_title + "get_html_title": filters.get_html_title, + "get_image": filters.get_image } JINJA_ENVIRONMENT = { diff --git a/plugins/filters.py b/plugins/filters.py index b52296f..a01acad 100644 --- a/plugins/filters.py +++ b/plugins/filters.py @@ -31,3 +31,7 @@ def get_title(instance): def get_html_title(instance): return get_attribute(instance, 'html_title') or get_title(instance) + + +def get_image(instance): + return get_attribute(instance, 'image') or (hasattr(instance, 'page') and get_attribute(instance.page, 'name')) or '' diff --git a/theme/templates/extras/header.html b/theme/templates/extras/header.html index d590185..93dc8de 100644 --- a/theme/templates/extras/header.html +++ b/theme/templates/extras/header.html @@ -1,4 +1,4 @@ -