Extension talk:ImageMapConversion

Missing DownloadEdit

Any chance of some one restoring the download for this extension. The listed SVN was down and now is showing as 404, and the main link requires a htaccess login.

-- 19:21, 30 October 2009 (UTC)Reply[reply]

Updated for MW 1.11Edit

I noticed a slight problem with MW1.11 - an error message due to one function (loadMessages) not returning a valid value. It now returns true.

If you choose to upgrade, just download and replace ImageMapConversion_body.php; it's the only one with a change in the code.

--Michael Daly 19:20, 28 January 2008 (UTC)Reply[reply]

What does this extension do?Edit

I am compiling image map resources and info here:

I do not understand what this extension does. How does one use it to convert an image map found on the web to one that can be used on a MediaWiki-based wiki? I figured out how to convert an image map manually, but an automated process would be very helpful. --Timeshifter 01:58, 31 August 2008 (UTC)Reply[reply]

The extension installs a special page on the wiki. The special page has a text area (with a Browse button) that allows the user to input the path and file name (on the local computer) of a file containing an HTML image map. It then takes the HTML format image map and converts it to the format required by the Imagemap extension.
The conversion is simple, since the HTML formats and the Imagemap formats pretty much map one-to-one. For example, the following HTML:
<area shape="poly" coords="520,80,606,56,615,100,565,115" href="/index.php Prince_Edward_County" title="Prince Edward County">
converts to:
poly 520 80 606 56 615 100 565 115 [[Prince_Edward_County|Prince Edward County]]
All that's done is to remove the HTML and the commas and interpret the href and title.
The extension can take an entire HTML page file. It will ignore everything before the first image map statement and stop after the closing image map statement (hence it will do only one image map in a file; multiple image maps in one HTML file will require the user to split the HTML file manually).
In processing the HTML, it will skip any nasty HTML, preventing the injection of malicious HTML.
--Michael Daly2 18:46, 31 August 2008 (UTC)Reply[reply]
Thanks for creating this extension. Where is this special page on the Commons or on English Wikipedia? I want to try it out. Does it only work on HTML files saved on my PC? Or can I point the extension to a web page?
If I see an image map on a page on the web that I want to convert should I save the web page in 2 parts (the HTML file and the files folder)? Or do I save just the HTML, and then save the image separately?
I am a basic webmaster so I know how to separate a web page in 2 parts. But others will not be able to do that. Is there a way to tell the extension to look at the 2nd or 3rd image map on a page? --Timeshifter 01:03, 1 September 2008 (UTC)Reply[reply]
Wikipedia does not use this extension. You can try it out on my wiki Kayakwiki's pool wiki. You have to use a file, so if you want to convert a web page, you'd have to capture the page's HTML and save it as a file on your computer. You'd have to save the image file separately and upload it to your wiki using the usual file upload page.
The extension only looks at the first image map on a page. You'd have to manually split it to get a second or third image map.
--Michael Daly2 18:00, 1 September 2008 (UTC)Reply[reply]
Thanks. I tried saving several web pages with image maps to my PC. Then I browsed to them from within the converter, and clicked "submit." No luck with any of them.
http://flagspot.net/flags/ie(.html - The converter seemed just to copy the HTML code without converting it.
The only thing that showed up in the results for the rest of the pages was a pound symbol (#), and nothing else. Here are the pages that did that:
commons:Template:Clickable map of Central America
http://www.december.com/html/demo/imagemap.html --Timeshifter 04:13, 3 September 2008 (UTC)Reply[reply]
All three work as expected for me.
The map of Ireland and the image map example convert just fine. The map of Central America contains an invalid "nohref" statement and gave an error message. When I removed the offending statement, it worked fine.
I could see some errors have been generated in my server's PHP error logs - I think these occurred when you were testing. How did you copy the page information? I simply selected "Save page as..." in Firefox and saved the page file as an html file, retaining the name from the web sites.
--Michael Daly2 16:14, 3 September 2008 (UTC)Reply[reply]
I get your results when I save the pages as "HTML-only" in Firefox (though the "nohref" result was with a different page - the december.org page).
My previous results occurred when I saved the pages as "complete" in Firefox. I don't understand why this would matter though, since both methods save the page as .htm HTML files. --Timeshifter 03:29, 4 September 2008 (UTC)Reply[reply]
I get the same results saving with "complete" or "HTML only". However, when I ran a diff check on them, there was quite a difference in things such as capitalization and such. I can't see any difference that would account for a problem with this extension.
I was working from memory when I identified the nohref problem - it was probably the same page as you identify.
--Michael Daly2 08:01, 4 September 2008 (UTC)Reply[reply]
I am using Firefox 2 instead of Firefox 3. I don't know if that matters, though. In my opinion Firefox 3 is not good for people like me with zillions of bookmarks. Lots of others are sticking with Firefox 2 also for now for various reasons.

(unindent) It would be nice to have a way to paste in the relevant HTML code directly into the conversion tool. Then people could experiment and leave lots of notes on this talk page about what works and what doesn't. I and others could add the edited notes to commons:Commons:Image map resources. --Timeshifter 09:05, 4 September 2008 (UTC)Reply[reply]

That's an idea. I created this extension to make it easy for me to convert my wiki from one imagemap extension to another. It was quick and dirty and I made it available to others. When I used it testing this stuff, I thought that pasting the HTML would be a good idea too.
I have to open this thing up and fix a few things - it isn't quite up to the latest standards for Mediawiki. I may make this change while I'm at it and possibly make a few improvements as well.
BTW - could you send me the HTML file that caused the bugs? I could use it to find out why the program errored and fix it - even if it's a corrupt HTML file, the program should not have errored.
--Michael Daly2 18:18, 4 September 2008 (UTC)Reply[reply]
I sent the HTML files via email. --Timeshifter 20:27, 4 September 2008 (UTC)Reply[reply]
Better late than never - I fixed this with version 1.2 on 2008-11-07. I should have responded to this when the fix was in. Sorry.--Michael Daly2 20:05, 3 March 2009 (UTC)Reply[reply]

Path problemEdit

Just to let you know that the extension did not work for me until I realize there was a path problem in ImageMapConvert.php, in this file I had to change:

...form method=post action="/index.php?title=Special...


Are you sure you have the path correctly set up in LocalSettings.php? If it is, then the form's relative address should find the root. It sounds to me like you have a non-standard directory layout. --Michael Daly2 03:12, 28 February 2009 (UTC)Reply[reply]
Hi Michael. Are you sure the "/" in front of index.php does not make it an absolute path instead of relative ? I've tried to play around with relative paths but no luck (specially because the colon after "Special") so for now I use the above trick first mentioned, dirty but works for me :-)
Sorry - I'm not using the right terms. The full path for "/index.php..." is expanded to a URL by adding the info for the wiki from the default root that the web server knows. It seems that the root in the web server is not the same as the root that LocalSettings.php determines - hence the difference requiring you to add "/my_correct_path_to_mediawiki..." to the extension. That's why I suggest you probably have a non-standard setup. You probably have some differences in the path to the root of the wiki compared to the default for a generic MW setup. Are you using aliases in Apache's config (e.g. in .htaccess)? Have you got some sort of short URL rewriting in .htaccess that isn't one of the standard ones found elsewhere on this wiki? Something is different in your wiki configuration, since you're the only person who has reported this problem. --Michael Daly2 19:39, 3 March 2009 (UTC)Reply[reply]
Hi Michael, thank you for your explanations. I've checked a bit everything regarding the path to my MediaWiki instance. What I can tell you is:
IP = "C:\\wamp\\www\\wikipedia";
ini_set( "include_path", ".;$IP;$IP/includes;$IP/languages" );
require_once( "includes/DefaultSettings.php" );
$wgScriptPath	    = "/wikipedia";
$wgScript           = "$wgScriptPath/index.php";
$wgRedirectScript   = "$wgScriptPath/redirect.php";
Can you spot anything non-standard in this config ? If yes please let me know. If not then it's not a big problem as the workaround I found works OK for me !

Hi, I have had the same problem, and tried a more general solution. Rather than using the specific workaround

...method=post action="/my_correct_path_to_mediawiki/index.php?title=Special...

I used a relative URL (no leading /) and it worked OK.

...method=post action="index.php?title=Speciall...
--Niall Teskey 21 April 2009
Hi Niall, I tried your generic workaround (i.e. removing the leading /) but then after submitting I end up on this page which does not work ("index.php" appears twice in the URL):
So in my case I have to use the specific workaround which after submitting leads me to the correct page i.e.:

Other problemsEdit

Hi Michael. I also have the two following problems:

  1. The ImageMapConverter uses the keywork "polygon" but the ImageMap extension complains and asks for "poly" instead. (The only easy workaround I've found is just to do a replace-all in a text editor but it is not very convenient)
  2. It seems that the ImageMapConverter has some problems handling the presence of special characters in URLs contained in the source image map. What I've experienced is when I have an URL like the following one in the HTML source:

it will get transformed by the ImageMapConverter into something like


This problem is quite annoying for me as I link to lot of anchors and I haven't found yet an easy workaround. Any help would be appreciated !

Except for these small problems I find this extension very useful, well done :-)))

Imagemap converter does not actually verify the shape type on input (e.g. rect, poly, circle etc). If it looks like a shape description, it just passes it through. That means that if the file you are using has shape="poly" in it, you get poly on the output. If it is shape="blort", you get blort on the output. That's why the input has to be valid HTML. Check the source file and ensure that it is shape="poly" in the file and not shape="polygon"
I realize this is not the most robust error checking, but this extension started as a cheap and dirty - I'll get it cleaned up "soon."
OK this sounds logical. The image map I use are generated from MS Visio diagrams and Visio uses "polygon" and the MediaWiki ImageMap extension uses "poly" hence the mismatch. As mentioned it's not a big problem as a simple manual replace-all can be done before or after the conversion.
If I open this up real soon, I'll see if I can slip in a conversion to rename polygon to poly for this. It must be an MS "feature."
Indeed MS have their own standards for everything... As you mentioned, if you can easily slip that conversion that would be great :-)
As far as the URLs go - I never tested URLs - the input is supposed to be a local file path. As the extension page states: you will see a text input line for a local file. I'll change the documentation to be more clear.
When (if) I get to fix up the error checking to be more robust and not so trusting of the quality of the HTML, I'll see what I can do about supporting URLs and not just files.
--Michael Daly2 20:01, 3 March 2009 (UTC)Reply[reply]
Regarding this problem, I am not sure if we are talking about the same thing: I was talking about the URLs specified inside the html tags "AREA", i.e. the URLs specified for each shape inside the ImageMap. Are you talking about this as well or about the "Source Filename:" TextBox to which you give the path to the HTML source file ?
Sorry - I was thinking of the input field on the page, not the AREA tag; my mistake.
Interesting - it could be the parsing algorithm I use is confusing the # in the URL with a # used for something else and is splitting the URL in some way. I'll look at it "soon" - perhaps this weekend if I find the time. --Michael Daly2 18:02, 5 March 2009 (UTC)Reply[reply]
OK that would be fantastic if you can fix this one, as reworking manually all the URLs/anchors one-by-one each time a conversion is done is quite a laborious process :-/ Many thanks !

Note - these problems have been fixed with release 1.3.--Michael Daly2 01:47, 16 March 2009 (UTC)Reply[reply]

Hi Michael, I've tried the new release (1.3) and I can confirm to you that the "polygon" and "#" fixes work fine for me, it makes the converter easier to use, many thanks for that :-)))

mediawiki svnEdit

It would be really helpful to have this in mediawiki's svn rather another svn. NSK Nikolaos S. Karastathis 03:37, 27 October 2008 (UTC)Reply[reply]

example of this wiki in use?Edit

is there an example of this wiki in use? Bigbull 05:11, 18 September 2011 (UTC)Reply[reply]

Author's SVN site is goneEdit

The author's SVN repository appears gone. Is there another source for this code?

Return to "ImageMapConversion" page.