+/**
+ * Returns true if this thumbnail is one that MediaWiki generates
+ * links to on file description pages and possibly parser output.
+ *
+ * $params is considered non-standard if they involve a non-standard
+ * width or any parameter aside from width and page number. The number
+ * of possible files with standard parameters is far less than that of all
+ * possible combinations; rate-limiting for them can thus be more generious.
+ *
+ * @param File $img
+ * @param array $params
+ * @return bool
+ */
+function wfThumbIsStandard( File $img, array $params ) {
+ global $wgThumbLimits, $wgImageLimits;
+ // @TODO: use polymorphism with media handler here
+ if ( array_diff( array_keys( $params ), array( 'width', 'page' ) ) ) {
+ return false; // extra parameters present
+ }
+ if ( isset( $params['width'] ) ) {
+ $widths = $wgThumbLimits;
+ foreach ( $wgImageLimits as $pair ) {
+ $widths[] = $pair[0];
+ }
+ if ( !in_array( $params['width'], $widths ) ) {
+ return false;
+ }
+ }
+ return true;
+}
+