Since MW 1.29, PagesImages defines the og:image tag using the images it gets from a page. The OpenGraphMeta extension allows defining an og:image using the #setmainimage tag. This results in the meta head tag being defined twice and the tag from PageImages overriding OpenGraphMeta's.
To reproduce the bug:
- have both extensions installed;
- go to a page that contains an image;
- use #setmainimage to define an og:image;
- view the source of the page, the meta og:image tag is defined twice.
See the proposed fix in PageImages::onBeforePageDisplay, it skips the displaying of the og:image tag if it has already been defined, giving a chance to other extensions to set a more appropriate one.
/** * @param OutputPage &$out The page being output. * @param Skin &$skin Skin object used to generate the page. Ignored */ public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) { // If the og:image tag has already been defined, skip. foreach($out->getMetaTags() as $tag) { if($tag[0] == 'og:image') { return; } } if(isset($out->getHeadItemsArray()['meta:property:og:image'])){ return; } $imageFile = self::getPageImage( $out->getContext()->getTitle() ); if ( !$imageFile ) { return; } // See https://developers.facebook.com/docs/sharing/best-practices?locale=en_US#tags $thumb = $imageFile->transform( [ 'width' => 1200 ] ); if ( !$thumb ) { return; } $out->addMeta( 'og:image', wfExpandUrl( $thumb->getUrl(), PROTO_CANONICAL ) ); }