Flags image and height attributes
-
Hi, the plugin is great but I run into one problem optimization problem, probably due to my poor PHP knowledge, but maybe someone will help.
I’m using Polylang free version for a website with two languages. I needed to use custom flags, I followed this tutorial:
https://polylang.pro/doc/can-i-use-my-own-flags-for-the-language-switcher/
and it was fine.
Then I needed to add width and height attributes (CLS/Pagespeed issue), so I googled another help topic:
https://polylang.pro/doc/filter-reference/#pll_custom_flag
and I have added as a plugin:
<?php
/**
Plugin Name: test-plugin
Plugin URI: https://www.your-site.com/
Description: Test
Version: 0.1
Author: your-name
Author URI: https://www.your-site.com/
**/add_filter( ‘pll_custom_flag’, ‘pll_custom_flag’, 10, 2 );
function pll_custom_flag( $flag, $code ) {
$flag[‘url’] = “https://myurl/wp-content/polylang/pl_PL.svg”;
$flag[‘width’] = 18;
$flag[‘height’] = 12;
return $flag;
}Now, attributes are working fine, but I get polish flag for both of the languages.
I would really appreciate some guidance, how to implement this code to replace both flags.
The topic ‘Flags image and height attributes’ is closed to new replies.