Add options for displaying images in query results
Closed, DeclinedPublic


A query like this:

{{#ask: [[Category:Images]] | ?Caption | ?Modification date | mainlabel=[[:Category:Images]] | limit=2}}

Normally produces a table of the image thumbnails. The only way I know of to control the thumbnail size is by editing LocalSettings.php with something like this:

$wgDefaultUserOptions['thumbsize'] = 0;
$wgThumbLimits = array(



Where 0 on $wgDefaultUserOptions would produce a 60px default thumbnail size for the entire wiki (not only the queries). Here's the relevant documentation of those parameters:$wgDefaultUserOptions$wgThumbLimits

Note also that these are user options that only affect new users and existing users that have not changed from the default. So, before this takes effect for the entire system, maintenance must be done with userOptions.php in the Mediawiki maintenance directory, as described here:

Obviously, that solution isn't going to work in practice, since people may have good reasons to choose a different thumbnail size from the default (small screen requiring smaller images, or poor vision, requiring larger ones).

In addition, the results obtained from image queries are sometimes thumbnails (on most pages), and sometimes just links to the file page (on Special:Ask "further results" pages, the semantic search page, and maybe others I don't know about).

Semantic Mediawiki needs to provide query options to control whether a thumbnail or a file page link is displayed. For thumbnails, an option needs to be available to control the thumbnail size.

Right now, this can only be done by creating and then specifying a custom template to use for the query.

That is OK for site developers in circumstances where the query is to be used frequently, but it's too much for an ordinary user to be required to do in casual queries, especially when using convenience features like Special:Ask and Semantic Search.

Version: unspecified
Severity: enhancement


Badon created this task.Jul 21 2011, 7:07 PM

Looks like a valid enhancement.

Badon added a comment.Jul 22 2011, 4:04 AM

This may be relevant to some parts of this bug report:

The suggested enhancements fall outside the scope of Devs project I'm afraid.

Badon added a comment.Jul 22 2011, 6:16 PM

Could you please explain?

He's working on the interfaces to create and run queries, not on how the results of queries are displayed. These are 2 quite different parts of the codebase.

Badon added a comment.Oct 30 2011, 7:02 PM

The broken image query bug has been fixed:

It is now possible to address this one.

I agree that this is a valid feature request. But we need to arrive at a concrete proposal before anybody can implement this. So far, this report only says that it should work somehow, but not how exactly. We can leave the developers figuring this out, of course, but it might be quicker/nicer to listen to the users here.

My suggestion is to include image formatting information as an "output format" into printouts (the text behind the #). This means that the information should not include |. Example:

{{#ask: ...

?my image property#130px


could be made to work. But there are many image options in MediaWiki, usually combined with a |. If we want to allow this to be set, some syntax must be used. How about replacing "|" with ":"? Is this workable for all options? Or do we have cases where ":" occurs already? For example, using "-" instead of "|" would not work since there are options like "text-top" which should not be read as "text|top".

Btw. using #outputformat also works for the main column as in the Category:Image query above. One merely has to hide the default main column and use the empty printout instead ("|#outputformat" should do).

I suppose we should start with a reference for the MediaWiki image documentation:

The image caption option could contain any arbitrary text, including for example a wiki link that contains a colon like this:


I suggest enclosing a caption option in quotes to prevent parsing of the text within, like this:


It might also contain <ref> tags, which are common. Beyond that, I'm not sure if anything crazier like parser functions are common or useful.

I made a post to the mailing list about the need for more input before this can be implemented:

I suggest to not support the caption at all. Trying to make pairs of " protect a link is not robust/feasible because links are parsed by MediaWiki, not by SMW. MediaWiki will not care about our decisions on how to escape links. But on the other hand, it might not be necessary to escape any formatting if we use a rare character. I suggest ";".

Setting captions in query printouts is not very useful in general, since the caption would be the same for all images in the query result. To make this useful, one would further need a mechanism for constructing captions from other property values. This is a kind of "combine multiple parts of a query result into a single display" for which there are as many desirable features as there are formatting options in MediaWiki; therefore we should leave this to the template format.

We can certainly do the basic options (size, border, etc.) if we agree on using ";" as a separator. We can possibly also do parameters that require "=" to be used, but this might confuse the current parser in SMW (remains to be seen). We can probably do complex formatting without limitations as long as no "|" or ";" occurs (which in turn might be unproblamatic if hidden in a template).

Badon added a comment.Oct 31 2011, 8:55 PM

Actually, setting captions in query printouts can be very useful in general. One use case produces only one image, for which a caption that describes what the image is would be helpful.

For example, let's say I've got an article about transportation. I could use a query to grab a certain "main" image of a horse from the horse article (which has a "main" property) to display on the article about transportation.

None of the captions on the horse article would be useful for an article about transportation, so I would need to set the caption in the query to something like:

"[[Horse]]s are a form of transportation. This is [[Otto Von Bismarck]]'s horse.<ref>some reference URL</ref>".

I agree semicolons are a good choice for a delimiter. Just ensure that nothing breaks if all parameters have a semicolon delimiter, including the last one. For example, strict usage of semicolons only as delimiters, and disallowing them on the last parameter, has broken Semantic Maps in templatized queries:

Badon added a comment.Jan 7 2012, 3:21 AM

As far as I can tell, there is no straightforward way to control the display of images in the new SMW 1.7, due to further regression in the list format, the array format, and lack of options in native image handling:

kroocsiogsi wrote:

This feature would make my life easier. My highest priority would be to support image size, and I was expecting something like this to work already:

{{#ask: ...

?my image property#130px


Supporting other image options is acceptable. The semicolon delimiter is acceptable. If I understand correctly, it would allow something like this:

{{#ask: ...

?my image property#frameless;border;none;text-top;50x30px


I personally do not care about support for link=, alt=, page=, or caption.

I am seriously considering uploading scaled versions of several hundred images on my wiki just to work around this limitation. It's either that, or maintain a whole bevy of custom output templates. If anybody has figured out a cute workaround (besides changing $wgDefaultUserOptions['thumbsize']) let me know.

kroocsiogsi wrote:

Patch to pass m_outformat as an image option

So let's set expectations: I don't know php, I don't know bugzilla, I don't know how to patch and diff, I don't know any best practices, and frankly it'd be a stretch to say I know how to code at all.

I've probably introduced a crashing bug and blasphemed God twice in these 26 characters, but by golly it appears to work for my purposes (id est, specifying an image size).

It would be super if this feature makes it into 1.8. Tell me what I have to do to make it so.

Attached: diff

Aklapper closed this task as "Declined".Mar 3 2015, 5:50 PM
Aklapper added a subscriber: Aklapper.

The Semantic MediaWiki developers requested in to move their task tracking to and to close remaining tasks in Wikimedia Phabricator. If you still face the problem reported in this task in a supported version of SMW, please feel free to transfer your report to . We are sorry for the inconvenience.

Add Comment