Last modified: 2012-08-03 23:48:34 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T32002, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 30002 - Add options for displaying images in query results
Add options for displaying images in query results
Status: ASSIGNED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Low enhancement with 1 vote (vote)
: ---
Assigned To: Markus Krötzsch
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-07-21 19:07 UTC by badon
Modified: 2012-08-03 23:48 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patch to pass m_outformat as an image option (402 bytes, patch)
2012-08-03 23:48 UTC, kroocsiogsi
Details

Description badon 2011-07-21 19:07:50 UTC
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(
        60,
        90,
        120,
        150,
        180,
        200,
        250,
        300
);

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:

http://www.mediawiki.org/wiki/Manual:$wgDefaultUserOptions
http://www.mediawiki.org/wiki/Manual:$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:

http://www.mediawiki.org/wiki/Manual:UserOptions.php

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.
Comment 2 Jeroen De Dauw 2011-07-21 19:28:33 UTC
Looks like a valid enhancement.
Comment 3 badon 2011-07-22 04:04:54 UTC
This may be relevant to some parts of this bug report:

http://www.mediawiki.org/wiki/User:Devayon/GSoC2011
Comment 4 Jeroen De Dauw 2011-07-22 14:44:57 UTC
The suggested enhancements fall outside the scope of Devs project I'm afraid.
Comment 5 badon 2011-07-22 18:16:27 UTC
Could you please explain?
Comment 6 Jeroen De Dauw 2011-07-22 19:01:30 UTC
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.
Comment 7 badon 2011-10-30 19:02:54 UTC
The broken image query bug has been fixed:

https://bugzilla.wikimedia.org/show_bug.cgi?id=30494#c4

It is now possible to address this one.
Comment 8 Markus Krötzsch 2011-10-30 21:11:57 UTC
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).
Comment 9 badon 2011-10-30 22:48:32 UTC
I suppose we should start with a reference for the MediaWiki image documentation:

http://www.mediawiki.org/wiki/Help:Images

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

[[Category:Images]] 

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

"[[Category:Images]]"

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:

http://old.nabble.com/Suggestions-needed-for-SMW-image-query-features-to32749227.html
Comment 10 Markus Krötzsch 2011-10-31 12:23:19 UTC
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).
Comment 11 badon 2011-10-31 20:55:58 UTC
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:

https://bugzilla.wikimedia.org/show_bug.cgi?id=30534#c4
Comment 12 badon 2012-01-07 03:21:50 UTC
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:

https://bugzilla.wikimedia.org/show_bug.cgi?id=32977

https://bugzilla.wikimedia.org/show_bug.cgi?id=32863
Comment 13 kroocsiogsi 2012-07-21 01:20:32 UTC
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.
Comment 14 kroocsiogsi 2012-08-03 23:48:34 UTC
Created attachment 10928 [details]
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.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links