Optional additions to that flag include width, height and a CSS CLASS.
The module has two subdirectories, 'countries' and 'states'. Within those directories are GIFs of the flags, and are accessed directly. A complete image tag is formed using the path to the specific flag GIF, plus optional width, height and CSS CLASS information. Setting either one of the optional width or height parameters causes the GIF to be re-sized, proportionally calculated.
A complete HTML 'img' tag is output in place of the world_flags tag. The 'alt=' is set to name of the flag, first letter capitalized. Width, height and CSS CLASS are inserted when necessary.
A global function is provided to display all the flags, or all the flag filenames, in a table.
Eventually, I will provide a way to insert a flag from a graphic menu.
Help instructions read:
World Flags module permits in-line tagging for the display of state and country flags.
The tags are replaced by GIF images of the country or state flag.
Acceptable tags are as follows:
[#FLAG=country]
[#FLAG=country, width, height]
[#FLAG=country, CSS CLASS]
[#FLAG=country, width, height, CSS CLASS]
or
[#USFLAG=state]
[#USFLAG=state, width, height]
[#USFLAG=state, CSS CLASS]
[#USFLAG=state, width, height, CSS CLASS]
If width > 0 and height == 0, or if width == 0 and height > 0, the parameter that IS zero is replaced with a value that is in proportion to the original dimensions of the image.
If both width and height are zero, the parameters ignored.
Additionally, if you would like to see a list of all available state or country flags, either by image or by filename, use this PHP function:
_world_flags_table( $filenames_only = false, $states = false, $width=0, $height=0)
Thank you for your time.
-Norm Strassner
norm@strassner.com
www.strassner.com
www.flashback.tv
www.fascinatinglearningfactory.org
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | inline_graphic_sets-6.x-1.0.zip | 633.79 KB | nstrassner |
| #5 | world_flags-6.x-1.0.zip | 670.08 KB | nstrassner |
| #3 | world_flags-6.x-1.0.zip | 670.35 KB | nstrassner |
Comments
Comment #1
nstrassner commentedFile attached.
Comment #2
avpaderno@nstrassner: You forgot to attach the file.
Comment #3
nstrassner commentedSorry. It looked like it attached to me (I browsed for it, attached it, and saved the message).
Now I realize that that I forgot about the 1mb upload limit. The program is small, but with both the state and country map gifs, it was a bit over 3 megs.
So, what you'll find in the upload is all of the states, but only countries that begin with "A" (Afganistan, Aruba, Australia, Austria, etc.).
I ask you for recommendations (if you approve of my work) regarding how to get the user the two data subdirectories, '/countries' and '/states'. I could provide a separate download page on my server, if necessary. Would I be the only developer to have data larger than a meg??
Best,
Norm
Comment #4
avpadernoThe module needs to implement
hook_filter(), nothook_nodeapi().Comment #5
nstrassner commentedYes, I see why you are right. That was my initial instinct (as you can see that hook was commented out), but for some reason I thought that the other hook was as good, but I do see the reasons to use hook_filter.
New file works with hook_filter.
Best,
Norm
Comment #6
avpadernoI would like to see this module integrating with Country Icons.
Comment #7
nstrassner commentedOne more note.
If approved, the final state and country flag GIFs will be of the same width. Height will vary slightly due to the actual shape of the flags, but widths will remain constant. Users can change the widths and heights inside the bracketed flag. The flags in the evaluation file I uploaded are of slightly different widths.
Unfortunately, due to the actual flag sizes, there is no way to make all of them the same dimensions, except by the user telling each flag to be exactly the same size. If that is the case, some of the flags will be somewhat distorted in shape, but I see no way around that, at least for now.
At least the native widths will be the same. If requested, I can work up two other directories that folks can download that will put the GIFs to the same height, instead of the same width. Also, the gifs can be brought into Photoshop, et.al. and altered by the user. The user can even change the flags, as long as they are labeled with the correct country or state name.
-Norm
Comment #8
avpadernoI am changing back the status, as no new code has been attached. Once you have update the code, change the status to .
Comment #9
nstrassner commentedComment #10
nstrassner commentedSorry. I did not change the status to 'needs review' on my last post which was...
I didn't get your Country Icons note before I changed and uploaded the source of World Flags.
I did not find the Country Icons module before, because I wrongly limited my search to "flags" and found nothing useful, so thank you very much for pointing me to Country Icons.
That said, I would like to discuss for a moment the pluses and minuses of incorporating the modules.
Country Icons is an API that uses direct PHP calls to access the icons, while my module lets any user with instructions on how to construct the tag which places a flag in their page or story to do so, without enabling PHP for the user(!!).
And while it is a plus to marry these two modules for the given flexibility, I suspect that not every user who requires icons will require the larger flag images (and vice versa) and having another few kilo- or megabytes of images that will never be used on a particular site seems like a waste of real estate to me, especially for sites with limited storage (yes, they exist!).
So, if you think I should add to Country Icons, I will go ahead and contact Tom Kirkpatrick and discuss it with him. Otherwise I'd be happy to have a stand alone module.
-Norm
Comment #11
avpadernoI was suggesting that your module should use the other module API to generate the necessary output; I was not referring to end users.
In such cases, your module would not be used either, as the users would use their own custom module.
It's not then the other module that has too many images, but it is yours that has few images (having just the flag images for the country with a name starting with A doesn't mean to provide the most used images).
The other module is able to provide a unique file that with the sprite technique avoid to load 100 different image files.
What I was suggesting is that your module would use the API given from the other module. This would means, for the end users, to not have two separated set of icons, and not have a downgrade caused from loading more than one file.
Comment #12
nstrassner commentedComment #13
nstrassner commentedI have examined the Country Icons module carefully and played with its exposed methods. While useful, I see a couple of problems, but please correct me if I am in error:
(1) As far as I can determine, each sprite needs to have the same dimensions, but please correct me if I'm wrong. All Country flags, and state flags for that matter, do not have the same dimensions.
(2) I tried to find a sprite generator (that actually worked), but the only ones I can find are online and are limited to either .5Mb or 1.0Mb zip files. With the size of my flags, the zip is > 3mb.
(3) So, I may be able to use this module as a required module if necessary, but I don't think I can use the sprites functionality.
As I had mentioned, the original zip file I made of the module and flags was over three megabytes, so I could not upload it to you. I have flags for 251 countries and all 50 states, but I only included a few country flags (just ones starting with 'A') so you could evaluate the module. I may have to make arrangements for users to download the images separately if I am not allowed to include them in the zip or tar file.
Comment #14
avpadernoNobody is expecting the dimension of the flags to be respected; if it is a matter of perfect reproduction of a flag (which cannot be perfect reproduction, in any cases) versus performance, then I think it's preferable the second one.
Effectively, I missed that part; I am not going to approve a module that uses 3 MB of images, though.
Comment #15
nstrassner commentedOk, we'll wrap this up shortly because I can see you will be insistent on me using the API module. For my own needs, on the educational site this is for, I'll use a customized version, but for the Drupal site offering, I'll implement the other module's API and upload new files in a day or so that hopefully meets your specs.
I realize that this module does not even approach anywhere near the value, complexity and usefulness of Views or Ubercart, but those modules are 3.4mb and 2.39mb, respectively so, with all due respect, I need to ask a pertinent question: How, exactly, are you determining the maximum acceptable size of a particular module?
Is there a set policy on that that I missed in the contributor's docs? (and if so, I apologize for not seeing it). I'm sure you'll agree that in all fairness it cannot be entirely subjective, but even it if is allowed to be so, there must be some consensus that applies(?)
What I will do is to provide a smaller version of the flag collection and offer users the option to download larger versions of the flags from another server. I believe that this is done quite a bit with other modules who require, or use in some way, PHP or JS code that is not GPL.
-Norm
Comment #16
avpadernoThe difference is that in those modules there aren't 3 MB of images, and 16 KB of code.
I am changing the status back to the correct one.
Comment #17
nstrassner commentedI actually do thank you for having me interface with Country Icons, as it has given the module much greater flexibility.
You'll see by the readme.txt file (and help) that I made quite a few changes and now allow easy additions of move graphic set directories and programmatic search options.
Also, the name is changed to Inline Graphic Sets.
As an example of a new graphic set, I included a state flag set that's about 512k. I can make it smaller if you insist, but I would like to offer it as is. Additional sets can be made by the user, or downloaded from my server (eventually).
I look forward to your review.
[Edited by kiamlaluno to remove the sentence all in bold]
Comment #18
tr commentedI think integrating with Country Icons is the right way to go, as there are already way too many modules that offer flag icons for special purposes, where they could be leveraging the general-purpose Country Icons. By the way, Country Icons was created when mrfelton adopted the ip2cc module, which *was* one of those many modules that incorporated flag icons for a special purpose. mrfelton broke the flag functionality out into its own module because that's what makes sense, with the intention that any module that needs flags should use Country Icons instead of reinventing the wheel. So you see, Country Icons is specifically meant to address this need.
That said, it seems the main benefit you're adding is an input filter that recognizes tokens for graphics. That could be useful, but it seems to me a better way to do it would be to define your tokens by implementing the hooks the Token module provides for just this purpose. Then the Token Filter module would allow you to use your tokens anywhere you could use an input filter. By adding Token support into Country Icons you will make Country Icons more powerful and leverage off of existing and familiar modules like Token, reducing the amount of special-purpose code.
Additionally, Token has been moved into Drupal core for Drupal 7, which means it makes even more sense to build upon Token rather than to roll your own tokens.
Aside from this, there are two problems I see with the code as posted in #17:
1) There doesn't seem to be a statement about the provenance of the icons - are these GPL icons? Did you make them yourself or did you obtain them from some GPL'd source? If so, what is that source? Due to the detail involved, and the statement you made above about not having the capability to turn them into sprites, I'm guessing you didn't make them yourself. They absolutely cannot be put into Drupal CVS without attribution and without knowing they're GPL licensed.
2) The code needs some serious scrubbing to conform to Drupal coding standards. You should install and use the Coder module to identify the changes you need to make.
3) Where's your hook_schema()? I don't see how this module can possibly install because you call drupal_install_schema('inline_graphics_sets') in your hook_install() but you don't have a hook_schema() implementation in your source code.
4) What's Thumbs.db? It's huge but I see no evidence in the code that it's used anywhere.
Comment #19
nstrassner commentedYour recommendations are well taken. As a relative newbie (to Drupal, not to programming), I see the value in accessing the Token module and keeping the code lean and mean. I will examine the Token module in detail and see how I can work with it.
I collected these flags from non-copyrighted (e.g. public domain) sources over years for use in my video post production projects for various clients. I also have spent the last few days writing a program called "SpriteO'Matic" that makes sprites and sprite CSS files, so that won't be a problem.
As neat as I have tried to be, I'm sure it is far from perfect, so I will do what you suggested.
Yes, that was an oversight and thanks for pointing it out.
I keep forgetting to delete that file. MS Windows makes that hidden file for internal use in any directory that includes graphic files (much the same way Macs have used resource forks). It is entirely unnecessary and I will make sure I delete it from any further graphic directories.
This will take awhile, as I need to completely familiarize myself with the Token module.
Thanks for the report.
Comment #20
avpadernoThere have not been replies from the OP in the past 7 days. I am marking this report as .
Comment #21
avpadernoPlease read the following links as this is very important information about CVS applications.