(Spun out of T92457)
@Stephen points out the "originalimage" field of a page preview could be a video e.g. https://en.wikipedia.org/api/rest_v1/page/summary/Completing_the_square
{ "type": "standard", "title": "Completing the square", "displaytitle": "Completing the square", "namespace": { "id": 0, "text": "" }, "titles": { "canonical": "Completing_the_square", "normalized": "Completing the square", "display": "Completing the square" }, "pageid": 303500, "thumbnail": { "source": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Completing_the_square.ogv/320px--Completing_the_square.ogv.jpg", "width": 320, "height": 240 }, "originalimage": { "source": "https://upload.wikimedia.org/wikipedia/commons/3/3d/Completing_the_square.ogv", "width": 640, "height": 480 }, "lang": "en", "dir": "ltr", "revision": "836342689", "tid": "0f82bedc-3fa5-11e8-8178-ff9ff9b54684", "timestamp": "2018-04-14T05:31:14Z", "description": "technique used to solve a quadratic equation.", "content_urls": { "desktop": { "page": "https://en.wikipedia.org/wiki/Completing_the_square", "revisions": "https://en.wikipedia.org/wiki/Completing_the_square?action=history", "edit": "https://en.wikipedia.org/wiki/Completing_the_square?action=edit", "talk": "https://en.wikipedia.org/wiki/Talk:Completing_the_square" }, "mobile": { "page": "https://en.m.wikipedia.org/wiki/Completing_the_square", "revisions": "https://en.m.wikipedia.org/wiki/Special:History/Completing_the_square", "edit": "https://en.m.wikipedia.org/wiki/Completing_the_square?action=edit", "talk": "https://en.m.wikipedia.org/wiki/Talk:Completing_the_square" } }, "api_urls": { "summary": "https://en.wikipedia.org/api/rest_v1/page/summary/Completing_the_square", "edit_html": "https://en.wikipedia.org/api/rest_v1/page/html/Completing_the_square", "talk_page_html": "https://en.wikipedia.org/api/rest_v1/page/html/Talk:Completing_the_square" }, "extract": "In elementary algebra, completing the square is a technique for converting a quadratic polynomial of the form", "extract_html": "<p>In elementary algebra, <b>completing the square</b> is a technique for converting a quadratic polynomial of the form</p><dl><dd><span class=\"mwe-math-element\"><img src=\"https://wikimedia.org/api/rest_v1/media/math/render/svg/126c6935d3dd9f1c1da0c388ca2799be4f6f237c\" class=\"mwe-math-fallback-image-inline\" aria-hidden=\"true\" style=\"vertical-align:-0.505ex;width:12.629ex;height:2.843ex;\" /></span></dd></dl>" }
Looking at our code, if thumbnail source does not contain "px-" in the title , it will fall back to the originalimage
https://upload.wikimedia.org/wikipedia/commons/thumb/3/3d/Completing_the_square.ogv/Completing_the_square.ogv.jpg
We'll need to guard against that from happening.
See also: https://phabricator.wikimedia.org/T92457#4122197
Developer notes
A test has been written here - https://gerrit.wikimedia.org/r/430665
QA instructions
- Hover over these two links with a retina monitor and make sure the page previews do not have images in them
- Hover over the same two links with a non-retina monitor and make sure the page previews do have images in them