Skip to content

Commit

Permalink
bug #6023 Fix country field flags in Safari browsers (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 4.x branch.

Discussion
----------

Fix country field flags in Safari browsers

Fixes #6015.

Safari has issues with SVG images that don't define their dimensions. It's enough to set one of the two height/width. In our case, controlling the height is more important, so let's set the height explicitly. This doesn't change anything in the other browsers.

Commits
-------

5ff74d0 Fix country field flags in Safari browsers
  • Loading branch information
javiereguiluz committed Nov 16, 2023
2 parents ed2cbbc + 5ff74d0 commit d66ff09
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Resources/views/crud/field/country.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{% if show_flag and not show_name %}
{% for flag_code, country_name in field.formattedValue %}
{% if flag_code is not null %}
<img class="country-flag" alt="{{ country_name }}" title="{{ country_name }}" src="{{ asset('images/flags/' ~ flag_code ~ '.svg', ea.assets.defaultAssetPackageName) }}">
{# the explicit height is needed to avoid issues with SVG images in Safari browser #}
<img class="country-flag" height="17" alt="{{ country_name }}" title="{{ country_name }}" src="{{ asset('images/flags/' ~ flag_code ~ '.svg', ea.assets.defaultAssetPackageName) }}">
{% endif %}
{% endfor %}
{% elseif show_name and not show_flag %}
Expand All @@ -19,7 +20,8 @@
<span>
{%- if show_flag -%}
{%- if flag_code is not null -%}
<img class="country-flag" alt="{{ country_name }}" title="{{ country_name }}" src="{{ asset('images/flags/' ~ flag_code ~ '.svg', ea.assets.defaultAssetPackageName) }}">
{# the explicit height is needed to avoid issues with SVG images in Safari browser #}
<img class="country-flag" height="17" alt="{{ country_name }}" title="{{ country_name }}" src="{{ asset('images/flags/' ~ flag_code ~ '.svg', ea.assets.defaultAssetPackageName) }}">
{%- endif -%}
{%- endif -%}

Expand Down

0 comments on commit d66ff09

Please sign in to comment.