Add get image helper
This commit is contained in:
parent
ac924536d9
commit
c1e67fef8b
3 changed files with 7 additions and 2 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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 ''
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<header id="header" class="bg-primary image" data-image="{{ instance.image or (instance.page and instance.page.image) }}">
|
||||
<header id="header" class="bg-primary image" data-image="{{ instance|get_image }}">
|
||||
<div class="header-content">
|
||||
<div class="header-content-inner">
|
||||
<h1>{{ instance|get_title }}</h1>
|
||||
|
|
Reference in a new issue