The array passed to scoreFromTable() sometimes contains strings. This forces the return to cast to an integer so that math performed with the result does not throw a non-numeric warning.
sometimes contains strings
Can you provide an example of where this occurs? The patch looks fine but we'll need a way to replicate and verify there is a problem here.
I'd rather fix the issue in scoreFromTable if possibly as it doesn't sound like we should ever be generating strings here.
Ok, cool! Then I believe the issue might be related to this mistake: https://gerrit.wikimedia.org/r/483098.
My next question is how your wiki can contain images that are reported to have 0 pixels with? Can you please check if you have a custom $wgThumbLimits setting?
Another idea I have is that the PageImages code is – for some reason – executed for files that are not images. E.g. audio files don't have a width in pixels. Two hooks trigger the code in question: ParserMakeImageParams and AfterParserFetchFileAndTitle. I believe the first is only executed for actual images, but the second might be executed when a gallery contains audio files. This would indeed be a more complicated bug in the PageImages extension.
The $wgThumbLimits setting is default/stock in the Gamepedia stack.
The Extension:EmbedVideo that Gamepedia uses has a media handler for video/audio files(in game character audio) and these tend to get used in infoboxes near the top of articles. However, that code is supposed to enforce width for the containers for browser media controls. I will have to do some in depth testing on this.