-2

I am using ISO 3166-1 alpha-2 codes for countries as a taxonomy in several pages of a given type.

When listing those pages in a view, I would like to display the corresponding country flag, rather than the two-letter code, e.g.

<img src="https://lipis.github.io/flag-icon-css/flags/4x3/it.svg" width="5px">

for

it

Is that possible, perhaps using CSS+JavaScript?

Many thanks!

1

For example code for a Drupal-based approach, check out the Flags module.

Also take a look at the Language Icons module, although this particular module works on languages, not taxonomy.

If you just want a CSS + JS solution, you should be asking on Stack Overflow, not here.

1
  • 1
    Flags module seems like a great option for this case. I'd just like to add that one of the common ways to implement it is to add the Flag field to your Taxonomy, so each term would have both the letter code and the image. Then in Views you pull the flag info through a Relationship, or through content View modes (you can create a mode where the letter code is always replaced with the image or something similar). – prkos Mar 8 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.