Tillägg:PageImages

From mediawiki.org
This page is a translated version of the page Extension:PageImages and the translation is 57% complete.
Outdated translations are marked like this.
Detta tillägg följer med i MediaWiki 1.34 och framåt. Därav behöver du inte ladda ner det igen. Du behöver däremot fortfarande följa de angivna instruktionerna.
This extension is under code stewardship review and not actively maintained (ärende T252249). No new feature requests will be considered during this period.
Manual för MediaWikitillägg
PageImages
Utgivningsstatus: stabil
Genomförande API , Parsertillägg
Beskrivning Lagrar information om bilder som representerar en sida
Författare Max Semenik (MaxSemdiskussion)
Senaste versionen pågående uppdateringar
Kompatibilitetsregler Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki 1.37+
PHP 7.3.19+
Förändringar i databasen Nej
Licenser WTFPL 2.0
Ladda ner
  • $wgPageImagesOpenGraphFallbackImage
  • $wgPageImagesDenylist
  • $wgPageImagesScores
  • $wgPageImagesNamespaces
  • $wgPageImagesAPIDefaultLicense
  • $wgPageImagesExpandOpenSearchXml
  • $wgPageImagesLeadSectionOnly
  • $wgPageImagesOpenGraph
  • $wgPageImagesDenylistExpiry
Quarterly downloads 132 (Ranked 50th)
Public wikis using 2,271 (Ranked 191st)
Översätt tillägget PageImages om det finns tillgängligt på translatewiki.net
Ärenden Öppna ärenden · Rapportera en bugg

Tillägget PageImages samlar in information om bilder som används på en sida.

Målet är att returnera den bäst lämpade miniatyren som associeras med artikeln.

PageImages erbjuder också OpenGraph-protokoll-metadata för artiklar på wikin som tredjeparter såsom Facebook kan extrahera.

Installation

  • Ladda ner och placera filen/filerna i en katalog som heter PageImages i din extensions/-mapp.
    Utvecklare och personer som bidrar med kod borde istället installera tillägget från Git, med:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
  • Lägg till följande kod längst ner i din LocalSettings.php -fil:
    wfLoadExtension( 'PageImages' );
    
  • Konfigurera efter behov.
  • För att inledningsvis tilldela sidbilder till sidorna behöver man köra skriptet "initImageData.php" från katalogen tilläggsunderhåll. (/path/to/extensions/PageImages/maintenance/)
  • Yes Klart – Ta dig till Special:Version på din wiki för att bekräfta att tillägget har installerats ordentligt.

Konfigurering

$wgPageImagesDenylist is an array of sources for image denylists. Listed images will never be selected as page images. Examples:

$wgPageImagesDenylist = [
	// Page on local wiki
	[
		'type' => 'db',
		'page' => 'MediaWiki:Pageimages-denylist',
		'db' => false,
	],
	// Page on Wikimedia Commons, for other Wikimedia projects using direct DB access
	[
		'type' => 'db',
		'page' => 'MediaWiki:Pageimages-denylist',
		'db' => 'commonswiki',
	],
	// Page on Commons, for third-party sites using web access
	[
		'type' => 'url',
		'url' => 'http://commons.wikimedia.org/w/index.php?title=somepage&action=raw',
	],
];

More than one source can be used at the same time.

The denylist itself should contain wikilinks to files, the rest of the content is irrelevant (and can contain links to other pages). For example:

* [[:File:First denylisted file.png]]
* [[:File:Second denylisted file.jpeg]]
...

Remember that file links that result in images being added to the page will not work (these files are denylisted for a reason, right?), so don't forget the : in front of the links.

$wgPageImagesDenylistExpiry determines how long the list will remain cached, in seconds. Default: 15 * 60 (15 minutes).

$wgPageImagesExpandOpenSearchXml if set to true, PageImages will override the image detection in the opensearch API module with its own, more accurate results. Default: false.

$wgPageImagesNamespaces is an array of namespaces PageImages will be activated on. Default: NS_MAIN.

After the change, you'll have to run refreshLinks.php to generate the Page image information for those namespaces (hopefully, you can use the --namespace parameter to process only pages on the affected namespaces, since that script is very resource-intensive)

$wgPageImagesOpenGraph enables or disables the OpenGraph meta tags (could be useful if other extensions manage these tags) (1.39+). Default: true

$wgPageImagesOpenGraphFallbackImage is a URL to fallback image that will be shown when there is no image on a page. Default: false

Upgrade to MediaWiki 1.37+ notes

  • Since MediaWiki 1.37, $wgPageImagesBlacklist and $wgPageImagesBlacklistExpiry have been renamed to $wgPageImagesDenylist and $wgPageImagesDenylistExpiry respectively. There's no backwards compatibility code added to accept the old variable names, which means you should change the variable names during the upgrade, or define both variables in advance in preparation for the upgrade.
  • Since MediaWiki 1.37, the default page value for $wgPageImagesDenylist has been changed from MediaWiki:Pageimages-blacklist to MediaWiki:Pageimages-denylist. If you've added content to MediaWiki:Pageimages-blacklist on your wiki, you should rename it during the upgrade. If you want to prepare in advance for the upgrade, you can rename the page to the new name, and also set $wgPageImagesBlacklist (the old variable name) to the new page name, and the default value will be used when upgrading, which should match your previous change.

API

Tillägget PageImages erbjuder bildinformation genom att lägga till en prop=pageimages till properties -API:t för action=query.

prop=pageimages (pi)

(main | query | pageimages)
  • This module requires read rights.
  • Source: PageImages
  • License: WTFPL

Returns information about images on the page, such as thumbnail and presence of photos.

Specific parameters:
Other general parameters are available.
piprop

Which information to return:

thumbnail
URL and dimensions of thumbnail image associated with page, if any.
name
Image title.
original
URL and original dimensions of image associated with page, if any.
Values (separate with | or alternative): name, original, thumbnail
Default: thumbnail|name
pithumbsize

Maximum width in pixels of thumbnail images.

Type: integer
Default: 50
pilimit

Properties of how many pages to return.

Type: integer or max
The value must be between 1 and 50.
Default: 50
pilicense

Limit page images to a certain license type:

free
Only free images.
any
Best image, whether free or non-free.
One of the following values: any, free
Default: free
picontinue

When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.

Type: integer
pilangcode

Code for the language the image is going to be rendered in if multiple languages are supported

Example:
Get name and 100-pixel thumbnail of an image on the Albert Einstein page.
api.php?action=query&prop=pageimages&titles=Albert%20Einstein&pithumbsize=100 [open in sandbox]


Svar

{
  // piprop.name (and image exists)
  pageimage?: string // Source image filename (basename of original.source).
  // piprop.thumbnail (and image exists)
  thumbnail?: {
    source: string // Thumbnail image URL.
    width: number // Thumbnail image width in pixels.
    height: number // Thumbnail image height in pixels.
  }
  // piprop.original (and image exists)
  original?: {
    source: string // Source image URL.
    width: number // Source image width in pixels.
    height: number // Source image height in pixels.
  }
}

Exempelbegäran

Begära sidbild för en artikel.

Resultat
{
    "query": {
        "normalized": [
            {
                "from": "Lightbox_demo",
                "to": "Lightbox demo"
            }
        ],
        "pages": {
            "162510": {
                "pageid": 162510,
                "ns": 0,
                "title": "Lightbox demo",
                "thumbnail": {
                    "source": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Crystal_Clear_app_korganizer.png/50px-Crystal_Clear_app_korganizer.png",
                    "width": 50,
                    "height": 50
                },
                "pageimage": "Crystal_Clear_app_korganizer.png"
            }
        }
    }
}

Hur fungerar det?

När en sida sparas med en lokal bild kör parser krokarna ParserMakeImageParams och LinksUpdate. Tillägget PageImages svarar på dessa (och andra krokar) och lägger in en ny egenskap för sidan i tabellen page_props . Egenskapen heter page_image_free och dess värde är bildens namn.

Tillägget lagrar bara det valda bildnamnet. Andra funktioner kan visa bilden, såsom Sidinformation, Hovercards, and Mobilsök medan man skriver.

Bildval

Hur kan jag kontrollera vilken bild som associeras med en sida?

Sidbilder kommer listas på sidan ?action=info.

Hur väljer den bilder?

Alla bilder på sidan samlas in och ett betyg för varje bild räknas ut. Bilden med högst betyg väljs ut till sidbild. Om wikin konfigurerats så att bilder innehåller metadata som anger bilder som inte fritt licensierade, kommer bilden med bäst betyg som också är fritt licensierad också lagras. Hittas ingen lämplig bild eller har alla bilder dåliga betyg (dvs. låga betyg), kommer sidan inte ha några bilder.

Är $wgPageImagesLeadSectionOnly sant kommer endast bilder i huvudavsnittet övervägas. För nuvarande stämmer detta bara för Wikipediaprojekten, alla andra projekt kan dra bilder från utanför ledningen.


Hur betygsätts bilder?

The best possible page image on Wikimedia wikis is one of the first four images in an article which has a width/height between 400-600px and a height/width which is twice the value of the other dimension.

  • The algorithm is configurable.
  • Scores are calculated by a combination of:
    • Image widths as defined in $wgPageImagesScores['width']
      • In Wikimedia wikis, images smaller than 119 pixels are weighted highly negatively. Images with widths between 400px-600px are favoured, with a preference for the lower bound.
      • Images inside galleries are scored separately using $wgPageImagesScores['galleryImageWidth']
        • In Wikimedia wikis gallery images which are smaller than 100 are disregarded.
    • Position in document is also considered as defined in $wgPageImagesScores['position']
      • On Wikimedia wikis, only the first 4 images that appear in the document are considered.
    • The ratio of the image's width to height is considered $wgPageImagesScores['ratio']
      • On Wikimedia wikis a ratio of 0.4 to 3.1 is allowed, with 0.6 to 2.1 preferred.
      • The default value is $wgPageImagesScores['ratio'] = ["3" => -100, "5" => 0, "20" => 5, "30"=> 0, "31"=> -100]; with the key representing the width divided by height, rounded to the tenths place, and the decimal shifted one position to the right. An image 400px wide by 300px high would have a value of 13. The key's value is the scoring multiple associated with that ratio. Keys are selected increasing from zero with a new scoring multiple not taking effect until the key has been met or exceeded its value but not exceeded the next key. Any other images will score negatively and be discarded.

Hur uppdateras sidbilder?

PageImages fyller på med bilder när LinksUpdate -kroken körs, dvs. när en sida redigeras.

Kan jag utelämna vissa sidbilder?

Ja!

För hela wikin finns det en sida som administratörer kan redigera på MediaWiki:Pageimages-denylist (exempel). Alla bilder som ligger där kommer inte användas som sidbilder för artiklar.

För specifika sidor kan man lägga till |class=notpageimage till alla bilder som ska utelämnas. Exempelvis, [[File:Example.png|class=notpageimage]]. Fler detaljer finns på phab:T301588.

Hur man jag se en sidas sidbild?

Med hjälp av länken Sidinformation i sidospalten (eller genom att lägga till ?action=info i webbadressen) kommer du se det nuvarande bildvalet.

Hur kan jag rensa en dålig bild?

Sidbilden ändras bara när en länk i artikeln ändras. I nödfall får du lägga till/ta bort länkar från sidan, och återställa dem om det skulle behövas. Att rensa sidans cahce fungerar inte. För större nödfall rekommenderas det att skicka in ett Phabricator-ärende.

Varför är min sidbild en tom ruta?

Detta beror förmodligen på att din artikel innehåller video. Om en videofil börjar med en tom ruta kommer det att vara videons standardminiatyr och används den som sidbild, kommer det vara sidbild. Vi arbetar för nuvarande på att åtgärda detta, det vill säga att göra så att man kan ändra en videos miniatyr. Läs: phab:T92457 och phab:T22647 för mer information.

Se även