Important: This page is using cookies (cookies). Using this website without turning off cookies in browser, means that you agree for using it.
Buy Now! Features Downloads

Earn with us!

If you would like to start earning money with vBET join to Affiliate Program.
Results 1 to 8 of 8

Thread: Load flags with a css sprite

  1. #1
    Senior Member
    Join Date
    Dec 2009
    Posts
    276

    Default Load flags with a css sprite

    I've been experimenting with css sprites lately and found that it can cut down on server calls significantly. With them all of the flags could be loaded at once instead of one after another. This would effectively eliminate 52 server calls. Unfortunately there's no easy way to convert the flags into a sprite since the img tags are dynamically built in the code.

    There's some info here: Creating easy and useful CSS Sprites | Css Globe

    CSS Sprites generator

    Sorry for all the suggestions lately

    Edit - I think I found a way to do it. The name of the sprite just has to correspond to the name of the flag/language. Some editing of 'vbenterprisetranslator_flag' should work.

    So it would look something like this: (see the change in img src)
    Code:
    <a rel="novbseo" href="$url" <if condition="$code==$vbulletin->options['vbenterprisetranslator_forumlanguage']">onclick="document.cookie = 'vbet_language=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/'; return true;"</if>><img class="sprite $code" src="/clear.gif" alt="$name" <if condition="$vbulletin->options['vbenterprisetranslator_flags_noborder'] && !$highlight">border="0"</if><if condition="$highlight">border="1" style="border-color: yellow"</if>/></a>
    Last edited by tavenger5; 17-03-10 at 18:23.

  2. #2
    Michał Podbielski (vBET Staff) vBET's Avatar
    Join Date
    Oct 2009
    Posts
    3,037

    Default

    We will look closer on this idea At this moment we have to learn about css sprite and does it really can improve performance (browsers are caching images anyway). Request put into consideration

  3. #3
    Senior Member
    Join Date
    Dec 2009
    Posts
    276

    Default

    btw, here is what I just used to implement it (I don't use all 52, but the 13 most common)

    The change to vbenterprisetranslator_flag above (sprite can be renamed whatever - I used 'flags')

    This image:


    This added to extra css:
    Code:
    .sprite {background:url(/images/flags.png); width: 16px; height: 11px;}
    
    	.ar {background-position: -0px -0px;}
    	.zh-CN {background-position: -17px -0px;}
    	.en {background-position: -34px -0px;}
    	.fr {background-position: -51px -0px;}
    	.de {background-position: -68px -0px;}
    	.it {background-position: -85px -0px;}
    	.ja {background-position: -102px -0px;}
    	.ko {background-position: -119px -0px;}
    	.pl {background-position: -136px -0px;}
    	.pt {background-position: -153px -0px;}
    	**** {background-position: -170px -0px;}
    	.es {background-position: -187px -0px;}
    	.nl {background-position: -204px -0px;}

  4. #4
    Michał Podbielski (vBET Staff) vBET's Avatar
    Join Date
    Oct 2009
    Posts
    3,037

    Default

    As I understand highlighting active language will not work anymore?

    We will look close on that

  5. #5
    Senior Member
    Join Date
    Dec 2009
    Posts
    276

    Default

    active language still highlights - that uses a style where sprites use a class

  6. #6
    Michał Podbielski (vBET Staff) vBET's Avatar
    Join Date
    Oct 2009
    Posts
    3,037

    Default

    Nice We definitively will check it. Anyway - first we have lot of work with moving performance improvements from vBET4.x to vBET3.x which seems be more important right now. But be calm - we have your request on TODO list

  7. #7
    Senior Member
    Join Date
    Feb 2010
    Posts
    210

    Default

    I have this semi-working, but all my images are the same first flag, in the sprite.

  8. #8
    Michał Podbielski (vBET Staff) vBET's Avatar
    Join Date
    Oct 2009
    Posts
    3,037

    Default

    Done. Will be supported in next release - for all places where flags are used

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •