Fix Jinja2 template syntax error - replace break with proper logic
Fixed template syntax error where {% break %} is not supported in Jinja2.
Replaced with proper Jinja2 pattern using set variable and conditional check
to find first available thumbnail for Open Graph images.
Changes:
- Use {%- set og_thumbnail = none %} and conditional assignment
- Check og_thumbnail is none to ensure only first match is used
- Maintains same functionality with valid Jinja2 syntax
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
fe8388bc52
commit
e3b022e2c5
2 changed files with 12 additions and 6 deletions
|
|
@ -7,12 +7,15 @@
|
|||
<meta name="description" content="{{ product.description }}">
|
||||
<meta property="og:description" content="{{ product.description }}" />
|
||||
<meta property="og:type" content="article" />
|
||||
{%- set og_thumbnail = none %}
|
||||
{%- for thumbnail_key in ["thumbnail1", "thumbnail2", "thumbnail3", "thumbnail4"] %}
|
||||
{%- if thumbnail_key in product.extensions %}
|
||||
<meta property="og:image" content="{{ request.app["bucket.secure_uploads.get_endpoint"] }}/{{ product.s3_path }}/{{ thumbnail_key }}?ts={{ product.updated_timestamp }}" />
|
||||
{%- break %}
|
||||
{%- if og_thumbnail is none and thumbnail_key in product.extensions %}
|
||||
{%- set og_thumbnail = thumbnail_key %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- if og_thumbnail %}
|
||||
<meta property="og:image" content="{{ request.app["bucket.secure_uploads.get_endpoint"] }}/{{ product.s3_path }}/{{ og_thumbnail }}?ts={{ product.updated_timestamp }}" />
|
||||
{%- endif %}
|
||||
|
||||
{% if product.has_product_file and signed_get_object_url is not none %}
|
||||
<script>
|
||||
|
|
|
|||
|
|
@ -7,12 +7,15 @@
|
|||
<meta name="description" content="{{ product.description }}">
|
||||
<meta property="og:description" content="{{ product.description }}" />
|
||||
<meta property="og:type" content="article" />
|
||||
{%- set og_thumbnail = none %}
|
||||
{%- for thumbnail_key in ["thumbnail1", "thumbnail2", "thumbnail3", "thumbnail4"] %}
|
||||
{%- if thumbnail_key in product.extensions %}
|
||||
<meta property="og:image" content="{{ request.app["bucket.secure_uploads.get_endpoint"] }}/{{ product.s3_path }}/{{ thumbnail_key }}?ts={{ product.updated_timestamp }}" />
|
||||
{%- break %}
|
||||
{%- if og_thumbnail is none and thumbnail_key in product.extensions %}
|
||||
{%- set og_thumbnail = thumbnail_key %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- if og_thumbnail %}
|
||||
<meta property="og:image" content="{{ request.app["bucket.secure_uploads.get_endpoint"] }}/{{ product.s3_path }}/{{ og_thumbnail }}?ts={{ product.updated_timestamp }}" />
|
||||
{%- endif %}
|
||||
|
||||
{% if product.has_product_file and signed_get_object_url is not none %}
|
||||
<script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue