mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-11-24 00:13:27 +00:00
Add a parameter to deactivate OpenGraph meta tags
This can conflict with other extensions like SemanticMetaTags or OpenGraphMeta. Bug: T217307 Change-Id: Idfb006583edda8545b95609f047b2f301a9caa33
This commit is contained in:
parent
8adbbf5b8c
commit
3ab47c1061
|
@ -86,6 +86,11 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"PageImagesOpenGraph": {
|
||||
"description": "Enable the OpenGraph meta tags",
|
||||
"public": true,
|
||||
"value": true
|
||||
},
|
||||
"PageImagesDenylistExpiry": {
|
||||
"value": 900
|
||||
},
|
||||
|
|
|
@ -257,6 +257,9 @@ class PageImages implements
|
|||
* @param Skin $skin Skin object used to generate the page. Ignored
|
||||
*/
|
||||
public function onBeforePageDisplay( $out, $skin ): void {
|
||||
if ( !$out->getConfig()->get( 'PageImagesOpenGraph' ) ) {
|
||||
return;
|
||||
}
|
||||
$imageFile = self::getPageImage( $out->getContext()->getTitle() );
|
||||
if ( !$imageFile ) {
|
||||
$fallback = $out->getConfig()->get( 'PageImagesOpenGraphFallbackImage' );
|
||||
|
|
|
@ -51,8 +51,20 @@ class PageImagesTest extends MediaWikiIntegrationTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public function testGivenDeactivedOpenGraphOnBeforePageDisplayDoesNotAddMeta() {
|
||||
$outputPage = $this->mockOutputPage( [
|
||||
'PageImagesOpenGraph' => false,
|
||||
] );
|
||||
$outputPage->expects( $this->never() )
|
||||
->method( 'addMeta' );
|
||||
|
||||
$skinTemplate = new SkinTemplate();
|
||||
( new PageImages() )->onBeforePageDisplay( $outputPage, $skinTemplate );
|
||||
}
|
||||
|
||||
public function testGivenNonExistingPageOnBeforePageDisplayDoesNotAddMeta() {
|
||||
$outputPage = $this->mockOutputPage( [
|
||||
'PageImagesOpenGraph' => true,
|
||||
'PageImagesOpenGraphFallbackImage' => false
|
||||
] );
|
||||
$outputPage->expects( $this->never() )
|
||||
|
@ -76,6 +88,7 @@ class PageImagesTest extends MediaWikiIntegrationTestCase {
|
|||
public function testGivenFallbackImageOnBeforePageDisplayAddMeta( $expected, $fallback ) {
|
||||
$this->setMwGlobals( [ 'wgCanonicalServer' => 'http://wiki.test' ] );
|
||||
$outputPage = $this->mockOutputPage( [
|
||||
'PageImagesOpenGraph' => true,
|
||||
'PageImagesOpenGraphFallbackImage' => $fallback
|
||||
] );
|
||||
$outputPage->expects( $this->once() )
|
||||
|
|
Loading…
Reference in a new issue