Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Artur_G

    (@artur_g)

    I have managed to create:

    <?php
    /**

    Plugin Name: test-plugin

    add_filter( ‘pll_custom_flag’, ‘pll_custom_flag’, 10, 2 );

    function pll_custom_flag( $flag, $pl ) {
    $flag[‘url’] = “https://domain.eu/wp-content/polylang/pl_PL.svg&#8221;;
    $flag[‘width’] = 18;
    $flag[‘height’] = 12;
    return $flag;
    }

    Which gives me properly sized flag, but it’s one and the same flag for both of the languages. Would be great to have an example how to use it for two flags.

    Thread Starter Artur_G

    (@artur_g)

    I made it! Let me deliver beginner friendly solution.

    You need to add this code as a plugin, there is planty tutorials out there about this topic. You have to change only marked lines, the rest remains.

    add_filter( ‘pll_custom_flag’, ‘pll_custom_flag’, 10, 2 );

    function pll_custom_flag( $flag, $code ) {
    $flag[‘url’] = “https://domain.com/wp-content/polylang/{$code}.svg”; <— path to your local SVG files; file names: gb.svg (NOT en_GB.svg), pl.svg (NOT pl_PL.svg) and so on, I have no idea where to find list of those codes.
    $flag[‘width’] = 18; <— your desired width
    $flag[‘height’] = 12; <— your desired height
    return $flag;
    }

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Flags image and height attributes’ is closed to new replies.