Skip to content

Commit

Permalink
resolve product images macro
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMilek committed May 23, 2024
1 parent bc75735 commit c154e49
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% import '@SyliusAdmin/shared/helper/product.html.twig' as _product %}
{% import '@SyliusAdmin/shared/helper/product_image.html.twig' as product_image %}

{% set product = hookable_metadata.context.product %}
{% set variant = hookable_metadata.context.variant %}

<td>
<div class="d-flex gap-3 align-items-center">
<div>
{{ _product.image(product) }}
{{ product_image.image(product) }}
</div>
<div>
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% import '@SyliusAdmin/shared/helper/product.html.twig' as _product %}
{% import '@SyliusAdmin/shared/helper/product_image.html.twig' as product_image %}

<div class="py-1">
{{ _product.image(data) }}
{{ product_image.image(data) }}
</div>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% set variant = hookable_metadata.context.variant %}
{% set product = hookable_metadata.context.product %}
{% import '@SyliusAdmin/shared/helper/product_image.html.twig' as product_thumbnail %}
{% import '@SyliusAdmin/shared/helper/product_image.html.twig' as product_image %}

<td>
<div class="d-flex gap-3 align-items-center">
<div>
{{ product_thumbnail.image(data) }}
{{ product_image.image(product) }}
</div>
<div>
<div><strong {{ sylius_test_html_attribute('product-variant-name') }}>{{ variant.name }}</strong></div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% macro image(product) %}
{% if product.imagesByType('thumbnail') is not empty %}
{% set path = product.imagesByType('thumbnail').first.path|imagine_filter(filter|default('sylius_shop_product_thumbnail')) %}
{% set path = product.imagesByType('thumbnail').first.path|imagine_filter(filter|default('sylius_admin_product_thumbnail')) %}
{% elseif product.images.first %}
{% set path = product.images.first.path|imagine_filter(filter|default('sylius_shop_product_thumbnail')) %}
{% set path = product.images.first.path|imagine_filter(filter|default('sylius_admin_product_thumbnail')) %}
{% else %}
{% set path = asset('build/shop/images/200x200.png', 'shop') %}
{% set path = asset('build/admin/images/200x200.png', 'admin') %}
{% endif %}

<img src="{{ path }}" alt="{{ product.name }}" class="avatar avatar-l" />
<img src="{{ path }}" alt="{{ product.name }}" class="avatar" />
{% endmacro %}

0 comments on commit c154e49

Please sign in to comment.