Page MenuHomePhabricator

WikidataPageBanner when using page images generated API renders badly cropped images
Closed, ResolvedPublic

Description

This seems specific to MobileFrontend Beta mode. It does not happen in the default/stable mode.

Whenever the page's default associated image is of portrait aspect ratio, the banner brings negative value to the reading experience.

For example: https://en.m.wikipedia.org/wiki/Tank_Girl_(film)

Screen Shot 2016-04-01 at 04.13.29.png (1×2 px, 793 KB)

Short the top portion of someone's hair. Poorly cropped and rather pixelated due to it being stretched beyond the nominal size of the original photo. Presumably in a situation like this (bad aspect ratio, image too small) it may be better left out.

Origin of the image:

Screen Shot 2016-04-01 at 04.13.33.png (968×2 px, 583 KB)

  • If the autogenerated image by page images is not landscape it should not be used

Guidelines:
a) Do not allow images where width < 1.5 * height.
b) Find out the best place to implement ignoring of banner and implement.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

We should use lead images on layouts > 500px width IF only the image is landscape. we shouldn't use lead images otherwise.

this is a stop-gap solution till I work on solid, good looking, edge case proof layouts for mobile-on-desktop as part of my pet project.

Jdlrobson renamed this task from WikidataPageBanner (Beta) often renders less-than-useful banners to WikidataPageBanner when using page images generated API renders badly cropped images.Nov 14 2016, 12:07 PM
Jdlrobson removed Nirzar as the assignee of this task.
Jdlrobson moved this task from In discussion to Epics on the Wikidata-Page-Banner board.
Jdlrobson added a project: Google-Code-In-2016.
Jdlrobson updated the task description. (Show Details)

does a general solution to ignore banner if image width < 2 *(image height) look acceptable?

@Sumit yes. 1.5 is a usual conversion factor we use for landscape and portrait. width < 1.5 * height.

thanks @Sumit

@Jdlrobson: To clarify, would you like to mentor this in Google-Code-In-2016 (as you added that tag)? Or maybe @Nirzar (see info)? :)

@Jdlrobson: To clarify, would you like to mentor this in Google-Code-In-2016 (as you added that tag)? Or maybe @Nirzar (see info)? :)

Imported as https://codein.withgoogle.com/dashboard/tasks/6225877616558080/

I'll be mentoring this one.

I will work to fix it in the next 2 days as a Google Code-in student. As far as I understood the task is to find the corresponding code section and add a check if the image is not landscape, right?

Hi @divadsn - to be more specific any images where the width of the image is less than 1.5 * height.
width:200px, height: 200px would not be allowed (200 < 1.5 * 200)
This should only apply to images generated automatically.
{{PAGEBANNER:SmallImage}} would still work as the editor has specifically overriden the default.

Hopefully the extension page will be of some use :) https://www.mediawiki.org/wiki/Extension:WikidataPageBanner

@Jdlrobson Thank you for the clarification, now I will setup my dev environment. One question before I start, will vagrant run fine on a old laptop with 4 GB RAM and Ubuntu 16.10 64-bit installation?

@Jdlrobson Thank you for the clarification, now I will setup my dev environment. One question, will vagrant run fine on a old laptop with 4 GB RAM and Ubuntu 16.10 64-bit installation?

@divadsn it should be fine but feel free to ask on #wikimedia-dev or #mediawiki irc in case of issue.

Vagrant should be fine. Note that you may need to manually setup WikidataPageBanner (see T152036)

@Jdlrobson Thanks, everything is ready to go! I will reply back when I'm done or when I will have a problem with Vagrant or the code.

@divadsn I go by the nick "codezee" on #mediawiki and #wikimedia-mobile on irc. You can ping for help if facing difficulty...

Change 324775 had a related patch set uploaded (by Divadsn):
Fix badly cropped images when using page images

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

Change 324775 had a related patch set uploaded (by Divadsn):
Fix badly cropped images when using page images

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

Change 324775 merged by jenkins-bot:
Fix badly cropped images when using page images

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

@Jdlrobson what do you mean with this comment here? How should I avoid sending the image to the template when we don't know about the image aspect ratio at that point?
https://gerrit.wikimedia.org/r/#/c/324775/4/includes/WikidataPageBanner.hooks.php@128

Change 325038 had a related patch set uploaded (by Divadsn):
Add check if $options['isAutomatic'] is true

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

Change 325038 abandoned by Divadsn:
Add check if $options['isAutomatic'] is true

Reason:
See change 324884.

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

Change 325038 restored by Jdlrobson:
Add check if $options['isAutomatic'] is true

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

Change 325038 abandoned by Jdlrobson:
Add check if $options['isAutomatic'] is true

Reason:
Whoops.. I see the patch from Thiemo uses empty so I think this is no longer needed. Let me know if I've got that wrong..

Thanks for all the patches! Please keep contributing!! :D

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