Change Header Image according to language? (Qtranslate)

Home Forums Plugin Integration Change Header Image according to language? (Qtranslate)

This topic is: resolved

This topic contains 2 replies, has 2 voices, and was last updated by  anitadash 4 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3368

    anitadash
    Participant

    Hey guys! I’m a beginner, and this is my first post. Hope you can help me! ­čÖé

    So, I’m working on this website┬áhttp://welovesampa.com/. The default language is portuguese, and there are going to be other languages available through Qtranslate.

    I would like for the Header Image to change according to language. I’m using this code on the CSS for the portuguese image:

    
    #branding {
    
    background:url(‘http://welovesampa.com/wp-content/uploads/2013/05/header01ptbr.png’) no-repeat 0 100%;
     margin-bottom:28px;
     padding:44px 0 235px 0; /* Bottom padding is the same height as the image */
     overflow: visible;
     }
     }
     #blog-title, #blog-title a, #blog-description {
     color:#blank;
     }
     #branding {
     background-position: center bottom;
     background-repeat: no-repeat;
     margin-top: 32px;
     }
     #blog-title, #blog-title a, #blog-description {
     display:none;
     }
     #branding {
     height:235px;
     width:940px;
     padding:0;
     }
    
    

    The English image would be http://welovesampa.com/wp-content/uploads/2013/05/header01en.png.

    Qtranslate Forum (http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=9) says this function exists:

    <?php if(qtrans_getLanguage()==’en’): ?>
     <img src="<?php echo $imgsrc; ?>" alt="English Image" />
     <?php endif; ?>

    But I don’t think it works in the CSS stylesheet directly.

    Oh, I’m so lost!!

    Any help is appreciated. Thank you so much!

    #3371

    Martin
    Participant

    I think a way of  doing this would be to add a new class to the body dependent on the language being used. Assuming the code snippet is correct the following should do this (in functions.php):

    function my_language_class_names($classes) {
    $classes[] = ‘currentLang-‘ . qtrans_getLanguage();
    return $classes;
    }
    add_filter(‘body_class’,’my_language_class_names’);
    

    Then in css apply as many languages as necessary (replace the xx)
    .currentLang-xx #branding {…}

    #3372

    anitadash
    Participant

    It worked perfectly!

    Thank you very much, Martin!!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Change Header Image according to language? (Qtranslate)’ is closed to new replies.