Divadsn has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324775

Change subject: Fix badly cropped images when using page images
......................................................................

Fix badly cropped images when using page images

Skips generating of banner HTML code when image is not landscape.
This fix should also allow when the editor has specifically overriden the 
default.

Bug: T131424
Change-Id: I1261cca946e8e0e87ad9446233096da4511a1443
---
M includes/WikidataPageBanner.functions.php
M includes/WikidataPageBanner.hooks.php
2 files changed, 9 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner 
refs/changes/75/324775/1

diff --git a/includes/WikidataPageBanner.functions.php 
b/includes/WikidataPageBanner.functions.php
old mode 100644
new mode 100755
index 3f2216e..b518787
--- a/includes/WikidataPageBanner.functions.php
+++ b/includes/WikidataPageBanner.functions.php
@@ -165,15 +165,20 @@
                        // use largest image url as src attribute
                        $bannerurl = $urls[count( $urls ) - 1];
                        $bannerfile = Title::newFromText( "File:$bannername" );
+                       $file = wfFindFile( $bannerfile );
+                       // don't auto generate banner if image is not 
landscape, see bug report T131424
+                       $fileWidth = $file->getWidth();
+                       $fileHeight = $file->getHeight();
+                       if ( $options['isAutomatic'] && $fileWidth < 1.5 * 
$fileHeight ) {
+                               return $banner;
+                       }
                        $templateParser = new TemplateParser( __DIR__ . 
'/../templates' );
                        $options['bannerfile'] = $bannerfile->getLocalUrl();
                        $options['banner'] = $bannerurl;
                        $options['srcset'] = $srcset;
-                       $file = wfFindFile( $bannerfile );
-                       $fileWidth = $file->getWidth();
                        $options['maxWidth'] = $fileWidth;
                        // Provide information to the logic-less template about 
whether it is a panorama or not.
-                       $options['isPanorama'] = $fileWidth > ( 
$file->getHeight() * 2 );
+                       $options['isPanorama'] = $fileWidth > ( $fileHeight * 2 
);
                        $options['isHeadingOverrideEnabled'] = $config->get( 
'WPBEnableHeadingOverride' );
                        $banner = $templateParser->processTemplate(
                                'banner',
diff --git a/includes/WikidataPageBanner.hooks.php 
b/includes/WikidataPageBanner.hooks.php
old mode 100644
new mode 100755
index a87290d..912918a
--- a/includes/WikidataPageBanner.hooks.php
+++ b/includes/WikidataPageBanner.hooks.php
@@ -98,6 +98,7 @@
                        $banner = $wpbFunctionsClass::getBannerHtml( 
$bannername, $params );
                        // attempt to get an automatic banner
                        if ( $banner === null ) {
+                               $params['isAutomatic'] = true;
                                $bannername = 
$wpbFunctionsClass::getAutomaticBanner( $title );
                                $banner = $wpbFunctionsClass::getBannerHtml( 
$bannername, $params );
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/324775
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1261cca946e8e0e87ad9446233096da4511a1443
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikidataPageBanner
Gerrit-Branch: master
Gerrit-Owner: Divadsn <divad.nnamtd...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to