Topic on Extension talk:PageImages

9cfilorux (talkcontribs)

I installed the 1.31 release of this extension on MediaWiki 1.31. It doesn't seem to extract images for any pages. I ran initImageData.php, I edited a page with an image, I purged the page, I added an image to another page, I restarted Apache, and I restarted MariaDB (not necessarily in that order). None of that did anything. I tried using the 1.32 release instead, but when I ran its version of initImageData.php it just gave me an unending stream of this: "PHP Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in /var/www/html/w/includes/media/FormatMetadata.php on line 1864". I don't know what that means. I tried the suggestion below to replace a line in LinksUpdateHookHandler.php, but that made initImageData.php refuse to run, claiming "Class 'PageImages\Hooks\Revision' not found". What's going on? Something really obvious I'm missing??

Edit: I just tried restarting Nginx and Varnish as well, since I'm using the Apache-Varnish-Nginx system Wikipedia has. No luck there either.

Ciencia Al Poder (talkcontribs)

You can't expect an extension for MediaWiki 1.32 to work on MediaWiki 1.31. Besides that, on 1.31 should work just fine. Maybe your image is very small for this extension to take into account. The image should be (depending on the configuration) at the leading section (section 0).

9cfilorux (talkcontribs)

Well, apparently so... but Special:ExtensionDistributor advises that "Most extensions work across multiple versions of MediaWiki, so if your MediaWiki version is not here, or if you have a need for the latest extension features, try using the current version.", so I thought the 1.32 version was worth a try. I considered using an even more advanced release, but that would probably have been even worse.

Extension:PageImages#How are images scored? talks about how images are scored relative to each other, including size, but it only discusses scoring of exact sizes (and aspect ratios) on Wikimedia projects. It does not say what the default settings are. As for the lead section, Extension:PageImages#How does it select images? says "If $wgPageImagesLeadSectionOnly is true, only images in the lead section will be considered. Currently it is true for only Wikipedia projects, all other projects can pull images from outside the lead."

Because the default settings are not described, I looked at the source code, making sure I had the 1.31 branch because that's what I'm currently running. (I have not configured any custom settings.) The extension.json file appears to contain the default values for $wgPageImagesScores and $wgPageImagesLeadSectionOnly. The default for the latter is true. The default for the former is:

		"PageImagesScores": {
			"value": {
				"position": [
					8,
					6,
					4,
					3
				],
				"width": {
					"@doc119": "Very small images are usually from maintenace or stub templates",
					"119": -100,
					"400": 10,
					"@doc600@": "Larger images are panoramas, less suitable",
					"600": 5,
					"601": 0
				},
				"galleryImageWidth": {
					"99": -100,
					"100": 0
				},
				"ratio": {
					"3": -100,
					"5": 0,
					"20": 5,
					"30": 0,
					"31": -100
				}
			}
		},

This means that "images smaller than 119 pixels are weighted highly negatively" is actually the default behavior, not just the setting for Wikimedia projects. I do not understand what is meant by the settings for "position" (weights for the first four images?) and "ratio". Surely "20" doesn't mean that width divided by height = 20 (e.g. 20:1). However, I would expect that "only the first 4 images that appear in the document are considered" and "the best possible images are images where the height is half the width or the height is double the width. Any images for which the ratio is less than 0.5 will score negatively and be discarded" also describe the default behavior.

The main page on my wiki looks like this (the rest is private). It has no sections and one image. This image was an unsized (defaulting to 300px, as I haven't set $wgThumbLimits to anything else) thumbnail of a 400x400 image. I uploaded two test images and tried putting them on the main page instead of that image: one that is 400x800, and another that is 400x200, in keeping with the statement that a 2:1 or 1:2 image is best. These were both also unsized thumbnails. API queries with prop=pageimages continued to return no image information for Main Page. I also found that the database query select * from page_props where pp_propname = 'page_image'; returns nothing.

It appears that PageImages is simply not finding any images. I'd like some advice on why this could be the case.

9cfilorux (talkcontribs)

It turns out the problem was I had PHP 7.3, which MediaWiki isn't fully compatible with. Now that I've downgraded to 7.2, PageImages works. Maybe this could be mentioned in the documentation.

Reply to "Does not work"