• Resolved vertigoxxl

    (@vertigoxxl)


    Hi,
    I have uploaded custom language flag image, but the language switcher in the menu still displays small flag. It is loading not my original image, but scaled down 12×12 image, even if I indicate larger size with CSS.

    Here is what I am getting on the page:

    <img loading="lazy" class="trp-flag-image" src="https://newbmi.xyz/wp-content/uploads/2021/12/flag-de-12x12.png" width="18" height="12" alt="de_DE" title="German">

    Please advise how can I fix this. I saw that many other users have the same problem, which remains unresolved for many months now.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    Thank you for writing to us

    The issue had already been replicated by one of my colleagues and sent to the development team. They will try to get it fixed as soon as their schedule allows it.

    Cheers,

    This issue it has not been yet fixed. It is quite annoying that the plugin is forcing a tiny version of the flag to be loaded. Do you have a date when this issue will be addressed?

    Thanks.

    Hello, i encounter the same problem and i saw the issue wasn’t solved on any of the support forums, so i searched for a way to fix it and ifound this worked:

    On your functions.php you have to remove the image_size given by the plugin to the flags that makes them crop.

    function wpdocs_remove_plugin_image_sizes() {
    remove_image_size( ‘trp-custom-language-flag’);
    }
    add_action(‘init’, ‘wpdocs_remove_plugin_image_sizes’);

    After you do that you have to regenerate your thumbnails, you can use a plugin to do that.

    And last you’ll have to give some css to make it look the way you like on your site:

    img.trp-flag-image 
    {
    	width: 55px!important;
    	height: 30px!important;
    }

    and that’s all, it worked for me, i hope it works for you.

    • This reply was modified 4 years, 2 months ago by marimarjm.

    I have the same problem but unfortunately this solution seems not working for me.
    🙁

    alezucchi

    (@alezucchi)

    I’ve found this line in class-language-switcher.php in TP’s folder

      // HTML code to display flag image
            $flag_html = '<img class="trp-flag-image" src="'. esc_url( $flags_path . $flag_file_name ) .'" width="18" height="12" alt="' . esc_attr( $language_code ) . '" title="' . esc_attr( $language_name ) . '">';

    how can i override this?

    alezucchi

    (@alezucchi)

    also this seems to be involved and refers to trp-custom-language-flag, but the code mentioned above is not working for me…

    * Returns the original flags path for original languages
     * Or the custom flag path for flags uploaded into the media library
     * The image is returned resized to the custom size dictated bu trp-custom-language-flag
     *
     */
    function trpc_flags_path_custom( $original_flags_path,  $language_code ) {
    
    	// only change the folder path for the custom languages:
    	$option = get_option( 'trp_advanced_settings', true );
    
    	if ( isset( $option['custom_language'] ) ) {
    		foreach ( $option['custom_language']['cuslangname'] as $key => $value ) {
    			if ($language_code === $option["custom_language"]["cuslangcode"][$key] && !empty($option["custom_language"]["cuslangflag"][$key]) ) {
    				$attachment_array = wp_get_attachment_image_src(attachment_url_to_postid($option["custom_language"]["cuslangflag"][ $key ]), 'trp-custom-language-flag');
                    return isset($attachment_array) && $attachment_array ? $attachment_array[0] : $option["custom_language"]["cuslangflag"][ $key ];
    			}
    		}
    	}
    	return $original_flags_path;
    }
    
    add_filter( 'trp_flag_file_name', 'trpc_flag_name_custom', 10, 2 );
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Custom flag image size’ is closed to new replies.