Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Our next available supporter will start replying to tickets in about 0.01 hours from now. Thank you for your understanding.

Tagged: 

This topic contains 20 replies, has 4 voices.

Last updated by Nigel 1 year, 5 months ago.

Assisted by: Nigel.

Author Posts
November 14, 2022 at 1:26 pm #12454619

david

after i cleared my chrome cache i figured out another problem. Language flags are pixelated.See screenshot.

Compressed theme here: hidden link

pixel.jpg
November 15, 2022 at 8:12 am #12460187

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

So your theme uses a custom library to generate the menu items, and that is responsible for adding the broken title attributes to the flags which are displayed as tooltips.

I dug into the code to identify where the issue is, and have produced a code snippet that you can add to your theme's functions.php file that resolves that problem.

/**
 * Fix menu title attributes on language switcher
 */
add_filter( 'nav_menu_link_attributes', 'wpmlsupp_fix_title_attributes', 10, 2 );
function wpmlsupp_fix_title_attributes( $atts, $menu_item ){

    if ( isset( $menu_item->object ) && $menu_item->object == 'wpml_ls_menu_item' ) {
        $atts['title'] = "";
    }

    return $atts;
}

Note that nothing has changed in WPML for some time that would account for any changes with how this works. (I tested back to WPML 4.4.12 with your current theme version and got the same behaviour.) As such, this is very much custom work.

The pixelated flags are because you are displaying small graphics (18 x 12) at larger sizes (70 x 28).

You can fix that by either using larger graphics for the flags, or by using CSS to target the flag images and display them at their native size.

November 18, 2022 at 7:00 pm #12492545

david

Hello, thank you very much. I added code to end of functions.php but now tooltip window with lanaguage name is not opening if mouse over flag at all.

November 21, 2022 at 7:32 am #12501605

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

That's correct. WPML language switchers don't feature a tooltip.

It should be possible to modify the code above to add such a feature, but now we are into custom coding, and if you are not comfortable doing that yourself you should get a developer to do it for you.

Start by inspecting the $menu_item attribute, it may already include the language name, or at least the language code.

November 21, 2022 at 11:48 pm #12507137

david

Hello, okay, but how is possible that before, it was displaying tooltip with language name correctly? So it was special feature of theme? Its kinda weird that wpml language switch doesnt allow to show tooltip with name - I thought wpml has this feature. Also I would like to ask - there is some problem withing WPML with displaying custom flags. If user want different and bigger flags than its in default, simply select flag upload feature dont wortk - flag is resized and not good quality. Only solution is to use custom flag upload and then overwrite flags in media/flags folder. Its weird that this is only solution. Why this has not been ever fixed? I think its serious flaw.

November 22, 2022 at 3:26 pm #12512993

Nigel
Supporter

Timezone: Europe/Madrid (GMT+02:00)

I don't know about the history of the site, but when I was testing the issue in this ticket I went back quite a lot of WPML versions, and the behaviour was the same, i.e. no tooltip from WPML itself.

The problem tooltip on your site was coming from the theme: if it used to be different, I expect it is changes in the theme (or libraries the theme depends upon) which have changed.

As for the custom language flags I tested this locally, and confirm that if you upload a custom flag then they are automatically resized to 18 x 12 px, and this is hard-coded into the plugin without the possibility to change the resulting image file size.

I can see that this was discussed internally 3 years ago and it was decided not to change this, as there didn't seem to be much demand.

The workaround is simple enough, but I think this is what you are already doing.

When you upload a custom flag image it is saved in wp-content/uploads/flags/ and you can simply overwrite the flag image found there with one with the same name and the desired larger dimensions.

I'm sorry that there isn't a solution within the normal UI available.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.