Extension talk:RandomImage/Archive

Method renderHook not loading
An email was sent to Rob Church, this is just to document the bug and provide a fix.

When installed and tested on MediaWiki 1.10.0, and 1.11.0, the extension would not render an imagebox and provided the following warning: Warning: call_user_func_array [function.call-user-func-array]: Unable to call RandomImage::renderHook in ${IP}/mediawiki-1.11.1/includes/Parser.php on line 626

The fault appears to be in the declaration of the renderHook method on line 48 of RandomImage.php If you modify;

to; the method becomes accessible and the extension works. --Zven 01:55, 12 February 2008 (UTC)

Empty captions
If the is not used and there is no starting paragraph the image rendering will screw up the page. This seems to be because a caption defined as an empty character or spaces  will get stripped out by the method removeMagnifier when it removes the div tags , in the process creating a div tag that looks like this; This tag is malformed and depending on the content can cause the left side bar to screw up. Caption content is defined in the method getCaption in RandomImage.class.php;

Instead of defining spaces as ' ', a UTF-8 character '&&#35;32;' seems to work. I modified this function to which checks that the $text is not empty and sends the UTF-8 character instead of empty or spaces that get stripped forming a div tag like this; --Zven 11:13, 12 February 2008 (UTC)

Incorrectly used &lt;randomimage> causes fatal errors
If someone puts  in an article then that particular article/page can throw fatal errors, only revertable by manipulating the query string to provide &action=edit in a long form url request for that page. The problem seems to be in the method removeMagnifier in the file RandomImage.class.php when entities such as &#38;nbsp; are present in the variable. A hack seems to be to use the DOMDocument::LoadHTML static method rather than DOMDocument::LoadXML at about line 118. This hack stops the fatal error, but the malformed tag does not work properly unless you close it by specifying --Zven 02:05, 19 February 2008 (UTC)

Float='center' does not work
In README you mention 'center' as valid value for float. That's not right, it should be 'centre'.

RandomImage.class.php:                 if( in_array( $float, array( 'left', 'right', 'centre' ) ) )

-- Landa

Center contra centre
I think it must be center in the source since it sets the.

The README is correct but there is a bug in RandomImage.class.php.

So line 47 'centre' must be replaced by 'center'.

--Tomas 21:26, 29 April 2008 (UTC)
 * All of these bug fixes are being incorporated into a patch on --Zven 22:48, 21 May 2008 (UTC)

Category Possible?
How it is possible to use only pictures from category: XYZ? The Command   Did not work.

No captions?
Is there a way to omit any caption and just have the image? 71.170.103.181 06:42, 15 December 2008 (UTC)

DOCTYPE/ Invalid HTML output
For some reason, this extension is adding its own doctype declaration, wrapping itself into a html/body tag and exporting unneeded comment data. I've tried to remove this but can't find where it's coming from - most likely the parse function. I just want it to output the div and image code. --75.158.70.23 10:33, 15 March 2009 (UTC)
 * I confirm this bug! --66.131.178.187 13:15, 4 May 2009 (UTC)
 * In use here, I confirm this bug. --Jlhenry 13:26, 4 May 2009 (UTC)
 * Here is the answer I received from the developer of this extension:


 * I hope that this could help someone to find a fix. --Jlhenry 14:27, 4 May 2009 (UTC)


 * This all stuff is added by function removeMagnifier (and DOM parser), I'm not aware of purpose in removing this small "magnify" image. Easiest way is to remove this function - so you can change


 * Sauron 13:30, 4 January 2010 (UTC)

False russian encoding with MW 1.12
The string of the description of a picture in Russian, writes Extension in the spoilt kind. For example, Russian word "Ошибка" is written so: "ÐžÑˆÐ¸Ð±ÐºÐ° " --80.93.116.233 10:38, 12 April 2009 (UTC)
 * Problem in French too. --66.131.178.187 21:00, 3 May 2009 (UTC)

RandomImage in a category?
Could I use in order to show a random image taken from a defined category? --Airon90 15:25, 5 May 2009 (UTC)

Possible article links?
Needing to see if it is possible to create a "link" for the random images when the choice option is utilized. For instance, I am needing anytime THIS choice is shown, it links to THIS page? Any information on process or even info on if this is possible (or in future versions) would be appreciated. --M1shawhan 22:36, 30 June 2009 (UTC)

For russian encoding
public function render { $title = $this->pickImage; if( $title instanceof Title && $this->imageExists( $title ) ) { return //$this->removeMagnifier( 				$this->parser->recursiveTagParse( base64_decode ($this->buildMarkup( $title )) //)			);		}		return ''; }

protected function buildMarkup ( $title ) { $parts[] = $title->getPrefixedText; $parts[] = 'thumb'; if( $this->width !== false ) $parts[] = "{$this->width}px"; if( $this->float ) $parts[] = $this->float; $parts[] = $this->getCaption( $title ); return ( base64_encode (, $parts ) . )); }

Can anybody put this in svn?

Possible to do w/o extension
I haven't used this particular extension, but in reading it over, I think that you can essentially achieve the same thing with a combination of Extension:VariablesExtension, Extension:ParserFunctions, and Extension:DynamicFunctions (which are 3 very common extensions that a lot of wikis use.) Here's the code:

[[File:{{#switch:{{#var:randimage}}
 * 1=file1.jpg
 * 2=file2.jpg|thumb|{{#switch:{{#var:randimage}}
 * 1=File 1 caption
 * 2=File 2 caption}}]]

--Duke33 17:43, 4 January 2010 (UTC)