bohnmedia/contao-flag-icons-bundle
Composer 安装命令:
composer require bohnmedia/contao-flag-icons-bundle
包简介
Contao 5 wrapper around lipis/flag-icons — render country flags via insert tag or Twig function.
README 文档
README
A small Contao 5 wrapper around lipis/flag-icons. It renders
country flags as <img> tags via an insert tag or a Twig function.
Installation
composer require bohnmedia/contao-flag-icons-bundle
Usage
Insert tag
{{flag_icon::de}}
renders
<img src="data:image/svg+xml;utf8,…" alt="Germany" width="40" height="30" class="flag-icon flag-icon--de flag-icon--4x3">
More examples:
{{flag_icon::de::ratio=1x1}}
{{flag_icon::de::ratio=1x1::width=24}}
{{flag_icon::de::alt=Country name}}
{{flag_icon::de::alt=}}
Twig
{{ flag_icon('de') }}
{{ flag_icon('de', '1x1') }}
{{ flag_icon('de', '1x1', 24) }}
{{ flag_icon('de', alt='Country name') }}
The alt attribute is the localised country name from Contao's Countries
service — German in a German page context, English in an English one, etc.
Parameters
| Parameter | Default | Description |
|---|---|---|
ratio |
4x3 |
Aspect ratio of the SVG. Allowed values: 4x3, 1x1. |
width |
40 |
Value for the width attribute. The height attribute is computed from the ratio (e.g. width=24 on 4x3 → width="24" height="18"). |
alt |
— | Override for the alt attribute. Pass an empty string for decorative use. |
If the country code is unknown (no matching SVG in the installed library), both the insert tag and the Twig function render as an empty string.
Styling
The bundle ships no CSS. Three BEM classes are emitted on every <img>:
flag-icon— block-level hook for all flagsflag-icon--{code}— country-specific modifier (e.g.flag-icon--de)flag-icon--{ratio}— ratio-specific modifier (e.g.flag-icon--1x1)
Use these to apply your own styles, for example:
.flag-icon { width: 1em; height: auto; vertical-align: -0.125em; } .flag-icon--1x1 { border-radius: 50%; }
height: auto ensures the height re-derives from the intrinsic aspect
ratio when you only set width in CSS.
License
MIT.
bohnmedia/contao-flag-icons-bundle 适用场景与选型建议
bohnmedia/contao-flag-icons-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bohnmedia/contao-flag-icons-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bohnmedia/contao-flag-icons-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 35
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-01