The language switcher dropdown uses the flag images from the language icons module. Unfortunately, those images are not of a uniform size and vary from 16x12 to 24x12. The language icons module includes a setting for flag display size which defaults to 16x12. The following html is output from the language icons module
<img width="16" height="12" title="Deutsch" alt="Deutsch" class="language-icon" src="/sites/all/modules/languageicons/flags/de.png">
whereas the javascript in the language switcher dropdown outputs
<img align="absmiddle" src="/sites/all/modules/languageicons/flags/en.png">
I'm not familiar enough with javascript to figure out how to add the fixed width/height to get a uniform flag display. For my purposes, a fixed size of 16x12 would be okay. Others might like to have the ability to change the display size as in the language icons settings.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | lang_dropdown-flag_size-1129392-9.patch | 52.64 KB | manfer |
Comments
Comment #1
dude4linux commentedI also just noticed that under the language switcher dropdown settings, with the JavaScript widget enabled, that while the Width of dropdown element: setting changes the width of the widget, the Row height: setting seems to be ignored. It looks like the row height is always the default of 24px. It would be nice if this were adjustable or varied by flag size if the display size is made a variable as suggested above.
Comment #2
hass commentedSame under D7. The module does not use
variable_get('languageicons_size', '16x12')for image sizes.As quick workaround you can add a CSS rule to your theme. I currently guess this
<img>tags are added by jquery.dd.js. I also have no idea how to add additional attributes to the image tag.Comment #3
manfer commentedWhen you configure your block to use language dropdown switcher javascript library by checking "Output as JavaScript widget instead of HTML select element" the flag size will not be taken into account as that library doesn't support to configure the size of icons. The only way to change size in this situation is, as specified in previous reply, to customize CSS file yourself.
When you configure language switcher block not using that javascript library, output as a select box, is when the flag size is applied. With this configuration only the flag of the actual language is shown after the select.
Maybe a little confusing but it is how it works. I don't know if it is even better to drop the possibility to configure the size in language dropdown switcher block to avoid this confusion.
Take in mind that language icons has a configuration option to use your own images by configuring the folder containing the flags. You can find that configuration option "Icons file path" at "admin/config/regional/language/icons". So it is not very difficult to customize your own flags for the languages your website support. Which would be in my opinion the best solution. Use flag images that are exactly the size you want them to be. I suggest to use as "Icons file path" a dir like "sites/default/files/language_icons/*.png" and place there the flag icons so no matter if there is an update your custom flags would be still in place. You can copy there the flags included with language icons and just change those that doesn't fit your needs.
Comment #4
hass commentedThe bug is not fixed. I've seen many settings in this lib that supports configuration...
Comment #5
manfer commentedThe javascript library used to output the language switcher dropdown is MSDropDown by Marghoob Suleman. The options of that library as we can see on code are:
There isn't any configuration for the width/height of the icon. The only size configuration options refer to the dropdown as a whole, height, rowHeight. And even those size options do nothing in actual version and only the CSS styles the dropdown.
And this is not a bug as the module works as designed and as I explained in previous reply so at most is a feature request. The only thing that could be done in this module is to add a configuration option to specify a custom CSS file, a custom theme for the dropdown so anyone could create its own look&feel. Don't change it again to a bug report please.
In my opinion for most people would be just better to configure custom flags in language icons so they don't have flags with different sizes avoiding any resize on the browser that would happen by specifying size in CSS.
Other option would be to suggest a different dropdown javascript library to use in the module to decide if it is better than actual used library or just fill a feature request against MSDropDown javascript library.
Comment #6
hass commentedHow about "style" or how about using any other jquery lib?
Comment #7
manfer commentedI don't think the inline style option will have any effect on the icon.
I'm going to change the way in which the icon is added so this module will always respect the icon supplied by language icons module as configured in that module configuration options, including the configured size.
About using other library I have no problem if someone suggest other library and is a better one to change the actual one in use. One feature I like of this library and I haven't seen in others is that when there is not enough room to open the dropdown downwards then it is opened upwards.
Comment #8
hass commentedI think there are many ways to solve. First i suggest dou set the size to the default via module css to 16x12. If there is a custom setting. Ou could add an inline css that override this css or users csn add a module replacement css to thei module. Otherwise extend the lib (or ask the maintainer) and as very last resort, rewrite the lib logic with jquery what may make it more lean for drupal, too. :-)
Comment #9
manfer commentedIndeed there are lots of ways to do things, but there isn't any need to complicate code. In the following patch I change how the icons are handle, even simplifying the way it is done now, to use always language icons configured icon size.
Anyway I still think the best we can do would be to have a custom folder with flags of the desired size, something that language icons allow to do.
Comment #10
hass commentedI thought of a 1-3 liner CSS patch only... not a 60KB patch :-( I cannot review now, but it looks like overkill.
Comment #11
manfer commentedThe long patch is only because of a rearrangement on files location, including some of the binary files moved to different folder, but the changes in code are not many.
Comment #12
7wonders commented#9 may be a big patch but I can confirm its working against latest dev
Comment #13
cesareaugusto commentedThanks 7wonders! Will this patch merged to the main release?
Comment #14
manfer commentedIn the new version that is going to be pushed very soon the dropdown apareance is handle with skins. The flag icon size would be configured on that CSS skin -all flags same size-. In the skins I'm going to bundle with the module the size is going to be 20x14. If someone wants different size he must create a custom skin. I will try to include instructions on how to create skins.