diff --git a/extension.json b/extension.json index aced163..b70684b 100644 --- a/extension.json +++ b/extension.json @@ -29,6 +29,7 @@ "InfoAction": "PageImages\\PageImages::onInfoAction", "ParserAfterTidy": "PageImages\\Hooks\\ParserFileProcessingHookHandlers::onParserAfterTidy", "ParserModifyImageHTML": "PageImages\\Hooks\\ParserFileProcessingHookHandlers::onParserModifyImageHTML", + "ParserTestGlobals": "PageImages\\Hooks\\ParserFileProcessingHookHandlers::onParserTestGlobals", "SearchResultProvideThumbnail": "PageImages\\Hooks\\SearchResultProvideThumbnailHookHandler::onSearchResultProvideThumbnail", "SpecialMobileEditWatchlist::images": "PageImages\\PageImages::onSpecialMobileEditWatchlistImages" }, diff --git a/includes/Hooks/ParserFileProcessingHookHandlers.php b/includes/Hooks/ParserFileProcessingHookHandlers.php index 57c938e..2e563c4 100644 --- a/includes/Hooks/ParserFileProcessingHookHandlers.php +++ b/includes/Hooks/ParserFileProcessingHookHandlers.php @@ -66,6 +66,24 @@ class ParserFileProcessingHookHandlers { $handler->doParserAfterTidy( $parser, $text ); } + /** + * @param array &$globals + */ + public static function onParserTestGlobals( &$globals ) { + $globals += [ + 'wgPageImagesScores' => [ + 'width' => [ + 200 => 10, + 1000 => 20 + ], + 'position' => [], + 'ratio' => [], + 'galleryImageWidth' => [] + ], + 'wgPageImagesLeadSectionOnly' => true + ]; + } + /** * @param Parser $parser * @param File $file diff --git a/tests/parser/pageImagesParserTests.txt b/tests/parser/pageImagesParserTests.txt new file mode 100644 index 0000000..1e3b753 --- /dev/null +++ b/tests/parser/pageImagesParserTests.txt @@ -0,0 +1,46 @@ +!! Version 2 + +!! test +PageImages with one image +!! options +property=page_image_free +!! wikitext +[[File:Foobar.jpg]] +!! html +
+property[page_image_free]=Foobar.jpg +!! end + +!! test +PageImages with two images +!! options +property=page_image_free +!! wikitext +[[File:Thumb.png]] +[[File:Foobar.jpg]] +!! html + +property[page_image_free]=Foobar.jpg +!! end + +!! test +PageImages with best excluded by wgPageImagesLeadSectionOnly +!! options +property=page_image_free +!! wikitext +[[File:Thumb.png]] + +== Section == + +[[File:Foobar.jpg]] +!! html + +