Extension talk:PageImages

Jump to navigation Jump to search

About this board

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": [
				"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" (talkcontribs)

Don't displayed images from infoboxes, please hepl to fix this. (talkcontribs)

in extension.json try higher numbers for the first position --> in config --> PageImagesScores -> value -> position.

i want the images of infoboxes to be a page image and it seems working well with these settings:

               "position": [






Reply to "images from infoboxes"

Manually trigger LinksUpdate on all Aritcles

Mojoaxel (talkcontribs)

The Extension works fine and I'm very happy with it. The question now is how to trigger the Plugin on all Articles. At the moment only images are shown after I changes an Article.

Is there a way to trigger LinksUpdate on all Articles manually?

Varlin (talkcontribs)

+1. It would be a basic feature... (talkcontribs)

Hey, it is possible to do it manually. I am currently having MediaWiki 1.31.

To manually trigger this for all articles you have to start the initImageData.php in extensions/PageImages/maintenance/ folder. I do not have shell/ssh support on my provider, so I had to use MaintenanceShell extension and change the $wgMaintenanceShellPath to the mentioned path.

It looks like there is also some problem (at least on my server) with the script and I couldnt get it work properly. After some debugging I saw that I had to change LinksUpdateHookHandler.php (in PageImages/includes/) the following:

$rev = $linksUpdate->getRevision();


$rev = Revision::newFromTitle($linksUpdate->getTitle());

And I managed to get all images on preview (using the Popups/PagePreviews extension)

Hope it helps someone

Pastakhov (talkcontribs)

thanks (talkcontribs)

Just running initImageData.php over shell did the job. THANK YOU!

Reply to "Manually trigger LinksUpdate on all Aritcles"

Is there a way to transclude the image of pull it from other pages.

1 (talkcontribs)

I have a reused element on my website where they display "page cards" , it shows an image and the name of the page, but I need to pull this information in a lot of different locations. And the image for the page might change where other pages which were just pulling a list need the latest information.

Is there way to do something like [[File:{{Name_Of_Page/PageImage}}]]

Reply to "Is there a way to transclude the image of pull it from other pages."
Titanshadow (talkcontribs)

So I've been using the OpenGraphMeta extension for ages now. As such most of my wiki has the #setmainimage tag for that extension, which seems to no longer work. I've been removing it from templates, which is most of the wiki's usage of the tag, which is fine. The problem is that if I remove it from the template, the wiki doesn't seem to load the image property unless I edit the individual page. Is it possible to force-update the entire wiki to load image properties for every single page?

Tinss (talkcontribs)

The #setmainimage tag still works, it's just that this extension overrides the og:image it defines with its own.

Have you tried deleting the entire wiki cache to force every page to be regenerated?

Reply to "Updating entire wiki..."
Alzi24 (talkcontribs)

In Extension:PageImages#How_are_images_scored?, there are several parameters that can be set to configure the scoring. But there is no description of the valid values and the defaults.

Reply to "The algorithm is configurable ..."
Draceane (talkcontribs)

Hello, is there any option to skip some images (e. g. from sidebar)? These aren't very representative at all...

Reply to "Loading image from sidebar" (talkcontribs)

I would like to use the Extension to insert in a template. So a reference-link could Show the and a Image.

Is there any tag or ability to make this happen with this Extension?

Reply to "Tag useage of the Exstension"
Bryandamon (talkcontribs)

After installing, none of my page images get added, and when I run PageImages/maintenance/initImageData.php I get the following warnings:

PHP Warning: array_flip(): Can only flip STRING and INTEGER values! in /htdocs/extensions/PageImages/includes/ParserFileProcessingHookHandlers.php on line 123
PHP Warning: array_flip(): Can only flip STRING and INTEGER values! in /htdocs/extensions/PageImages/includes/ParserFileProcessingHookHandlers.php on line 123

Reply to "PHP Warning on MW 1.31"

Exclude images in <ref> tags from being used.

1 (talkcontribs)

Annoyingly several pages use images placed inside references as the page image. I have tried to put these in blacklists or otherwise force the first image to be selected, however it would be nice to exclude images from references.

Reply to "Exclude images in <ref> tags from being used."