Extension talk:ImageMap (McNaught)

How to create map files
I want this - but how do I create the .MAP files? What is their format? Some examples would be really helpful.

Error messages
I'm getting 3 error messages on any webpage that uses

Linux support only?
Thanks for the help, but no go. It's not the filename I have wrong, it seems to be this line: $mapfile = "/var/www/html/$Mapurl"; which refers to a path that doesn't exist on my install. I wasn't looking hard enough at the error message it seems. The actual path to the .map file is \Program Files\EasyPHP1-8\www\wiki\images\6\63\GPINetArch.map

I fixed this by replacing that line with this block: if( defined( 'MW_INSTALL_PATH' ) ) { $IP = MW_INSTALL_PATH; } else { $IP = dirname( __FILE__ ); }   $mapfile = "$IP/../../$Mapurl"; which is pretty messy - I grabbed the MW_INSTALL_PATH from LocalSettings.php (I'm not a PHP programmer), but while it refers to the wiki directory for LocalSettings.php, it refers to the extensions directory for ImageMap.php - hence the /../../

I'm sure you could fix this up to be a bit nicer.

So - all working great now. Thanks for a great extension, I'd been looking for a while for something to do exactly this. I was having issues while change the ImageMap.php with changes not appearing - turns out to be a browser refresh issue, even with Ctrl+Refresh. This is what was happening with Show Preview and the saved page having different results.

No clickability
We just installed this extension on Kayakwiki, but having some trouble getting it to work. See my attempt here. It's showing the image, but not responding to mouse clicks at all, so I guess it's not picking up the map file properly for some reason. related discussion. Any suggestions?

Is it necessary to change an apache directive to make it recognice .map files. I think it must be. Now my map file does something similar to this example fish map file when viewing directly, whereas before it showed the files contents in plain text. My .map file contents now look like this:         <area shape="poly" coords="168,117,139,125,120,108,151,104" href="http://kayakwiki.org/index.php/Carribean" /> <area shape="poly" coords="144,190,156,250,185,258,170,230,200,194,208,158,143,127,122,163" href="http://kayakwiki.org/index.php/South_America" /> <area shape="poly" coords="332,58,313,84,329,96,347,128,373,108,387,106,395,84,389,77,396,71,375,71,359,65,356,83,348,74,331,67" href="http://kayakwiki.org/index.php/Middle_East" /> <area shape="poly" coords="438,167,498,173,558,172,498,141,477,96,502,91,523,27,375,7,313,19,314,45,334,63,354,80,359,65,375,71,396,71,390,78,394,84,388,108,405,142,415,142,428,123" href="http://kayakwiki.org/index.php/Asia" /> </PRE> I tried to mimmick your example above. See anything wrong there?

-- Harry Wood 15:02, 17 July 2006 (UTC)

$mapfile variable
I implimented the fix to the mapfile path on KayakWiki and it works fine. Thanks a lot for your help.

PS - Please don't take this as negative criticism, but as constructive. I think it would be a good time to modify your extension to be more "standard". For example, most other extensions that I've installed are set up to be installed in their own directory within /extensions/. For example, /extensions/SpamBlacklist/ or /extensions/ParserFunctions/. I installed yours as /extensions/ImageMap/ and it works fine. If you do this, it keeps all the extensions separate and that makes life easier for an admin. All you have to do is change your instructions and one line of code. As well, any future changes should reflect the appropriate directory structure.

The change is require_once( "extensions/ImageMap.php" ); should be changed to reflect the subdirectory and as well, should be preceded with $IP as per other extensions. E.g. my LocalSettings.php ends with:


 * require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );
 * require_once( "$IP/extensions/SpamBlacklist/SpamBlacklist.php" );
 * require_once( "$IP/extensions/ImageMap/ImageMap.php" );

Anyway, you've created a great little product and making it "standard" will endear you to all those harried wiki admins out there!

Thanks again! Michael Daly 06:07, 18 July 2006 (UTC)

Security issues
I noticed a couple serious security problems with this extension. It does no checking on the $Mapurl, so someone can use a ../../../.. path to display the contents of any file on the server. It also does no checking on the contents of the mapfile, so you can use it to bypass MediaWiki's HTML sanitizer and output any HTML (e.g., web forms, JavaScript, etc.) Use with caution. --GregU 05:33, 22 November 2006 (MST)
 * Imagemap (Alternate) provides the functionality of this imagemap extension but removes any HTML from the input file that is not specifically related to imagemap and area definition. It doesn't solve the problem of an errant URL in the file, but it eliminates malicious HTML.  Michael Daly 20:15, 16 May 2007 (UTC)

Usage from a template
Maybe a newbie question, but I didn't find the answer elsewhere... The extension works smooth for me unless I call it from a template where I pass the image and link name as a parameter like. If I do this, imagemap throws an error, saying something like " error: invalid titel in link in row 3" (actually I only have the German text which is " -Fehler: ungültiger Titel im Link in Zeile 3" and " -Fehler: In der ersten Zeile muss ein Bild angegeben werden" (in the first row an image needs to be specified, or so). --Ben Marx 08:54, 11 September 2007 (UTC)


 * This is a bug in Mediawiki. Nothing can be done.  It is not specific to imagemap, it is a general problem with embedding extensions within templates. Michael Daly 22:32, 17 September 2007 (UTC)