Extension talk:LinkedImage

From MediaWiki.org
Jump to navigation Jump to search

Replaced by core functionality[edit]

Now you can use the parameter link=.



... gives Name.jpg

Look at: Help:Images#Syntax

The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

This seems to not be working for 1.6.3 I just get a blank page.

with version 0.2 it should be working


I am working with MediaWiki an php4, so the code did not work for me.

Since I removed all public an private statements it work with php4.

I'm using MediaWiki 1.6.8 and php4, and I just get parser errors using this extension. Any help? --Mijunkin 04:58, 19 October 2006 (UTC)

I'm using Mediawiki 1.6.8 and I can't find a localconfig.php file. If I add include("extensions/LinkedImages.php"); to the top (or bottom) of Localsettings.php I get nothing but blank pages...

Perhaps the following could help, in Localsettings.php I did put
require_once($IP . '/extensions/LinkedImages/LinkedImages.php');  
and it worked! Abasota 15:12, 22 April 2007 (UTC)

Template usage?[edit]

This extension works fine for me, but when I try to use it in a template, it returns the internal error "Image constructor given bogus title." -- 23:20, 8 November 2006 (UTC)

I get the same result - the problem is that template parameters are not expanded before the linked image is used. e.g. <linkedimage>wikipage=Wiki Test img_src=Image:{{{imagename}}}.jpg </linkedimage> tries to find the image [[Image:{{{imagename}}}.jpg]] which then gives an error. Any Ideas how to solve this problem? --Sebastian.Dietrich 19:07, 13 April 2007 (UTC)

This has to do with how XML style parser extensions work. See Using DPL2 as a parser extension. Alan Trick 17:06, 16 May 2007 (UTC)
Is there a chance that you will provide a version which works as well as a parser function? See Using DPL2 as a parser function. Sebastian.Dietrich 12:32, 20 May 2007 (UTC)

Template Generalization[edit]

Could you please issue a more general template version, where the target Link could also be external to the wiki?

I mean to be able to put links such as: i.e: http://www.itu.int/ Abasota 15:12, 22 April 2007 (UTC)


I added a new version of the extension. Here's a more detail list of changes.

  • fixed XSS vulnerability with not escaping single quotes.
  • cleaned up code, removed sections that were never used, (and what in the world is up with public attributes and private accessor methods?!)
  • 'alt' attribute is now always output. It's a required attribute in XHTML.
  • replaces {{PAGENAMEE}} with appropriate value in URL. (this should be more generalized).

Alan Trick 17:15, 16 May 2007 (UTC)

Link to external URL[edit]

Would be very nice if we can link the image to an external URL.
To enable something like this:
<linkedimage> url=[http://del.icio.us/post?url={{fullurl:{{FULLPAGENAME}}}}&title={{FULLPAGENAME}}] tooltip=Save to Del.icio.us img_src=Image:Delicious.JPG </linkedimage>
Can you ajust the code to achive it?
Alain, 20 May 2007

Is SVG supported ?[edit]

I have categories by country and icons of national flags as SVG, linked on a page like this:

[[Image:Flag of South Africa.svg|border|100px|right|South Africa]]
Categorized into [[:category:Customers in South Africa]]

I'd like to LinkedImage to link to the other directly, something like this:

  wikipage=:category:Customers in South Africa
  tooltip=Customers in South Africa
  img_src=Image:Flag of South Africa.svg
  img_alt=Flag of South Africa

However I'm getting an empty <img src="" > attribute returned in the HTML.

I've also tried using the URL of the wiki-generated .png thumbnail, but that doesn't work either.

user:Andyd 14:03, 31 July 2007 (UTC)

additional arguments[edit]


Would anyone object horribly if I simply added an img_align argument?

As a version 0.4 if need be?

I've already done so on my Wiki - from a coder standpoint, it's nothing more than a copy of the img_border lines ... replacing "_border" with "_align"

Yes, I know align is out of favor with CSS, however so is _height, _width and _border.

Mean Dean 08:20, 29 October 2007 (UTC)


I'm still up for adding align, because it's fast-n-easy from both a coder point of view, but also in implementation - providing the content provider with knowledge of what they're about to do and where.

Still I'm thinking perhaps adding a 'class' argument would probably resolve the need for bringing in the rest of the syntax, such as vspace, hspace, etc ...

Thoughts, arguments, concerns?

Mean Dean 08:52, 29 October 2007 (UTC)

Question re Source[edit]

Shouldn't the source end with:


To paraphrase Neal Stephenson, is this a mistake or something brilliant I cannot grok?

--Standsure 17:59, 1 November 2007 (UTC)
Actually, included (or not) PHP source files may omit the closing php tag. It may even be regarded as better practice, since it prevents unwanted characters to be written to the standard output by accident.
- 21:50, 12 April 2008 (UTC)

External URL[edit]

Is there any way to make the link go to an external URL instead of a local page? --Jonathan Kovaciny 21:28, 16 November 2007 (UTC)

Yes, use Extension:ImageLink. Jean-Lou Dupont 22:10, 20 December 2007 (UTC)
How exactly would one go about using Extension:ImageLink to do this? I have installed the extension, but cannot figure out how to link to an external URL. Am I missing something obvious here? Also, can the ImageLink extension be used to create a centered image? --Sethleben 02:32, 30 December 2007 (UTC)

Quick and dirty External URL enabler:

public function getURL() { 
        global $wgArticlePath, $wgParser;
        if (strstr($this->wikipage, 'http://')) {
        	return $this->wikipage;
        } else {
        	$page = str_replace('{{PAGENAMEE}}', $wgParser->mTitle->getSubpageUrlForm(), $this->wikipage);
        	return str_replace( "$1", $page, $wgArticlePath);

--Preterit 15:31, 31 July 2008 (UTC)

Reduced image dimensions.[edit]

Is there any way to get the server to actually reduce the image dimensions, instead of just shrinking the full image? – Jonathan Kovaciny 21:45, 20 December 2007 (UTC)

No-Link option[edit]

Using this modified render() function if no wikipage is given then just a img tag will be generated, without anchor.

    public function render() {
        // sanity checking
        if ($this->img_src == '') {
            return htmlspecialchars( wfMsg( 'linkedimage_noimg' ) );
        // create mediawiki image object ...
        $this->image = new Image( Title::newFromText( $this->img_src ) );
        // return link
		if ($this->wikipage == '') {
            return "{$this->getImg()}";
		else {
        return "<a href='{$this->getURL()}'{$this->getTooltipHTML()}>{$this->getImg()}</a>";

--Venicewiki 17:18, 20 October 2008 (UTC)