- // Check if the parameters can be extracted from the thumbnail name...
- } elseif ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) {
+ }
+
+ // FIXME: Files in the temp zone don't set a mime type, which means
+ // they don't have a handler. Which means we can't parse the param
+ // string. However, not a big issue as what good is a param string
+ // if you have no handler to make use of the param string and
+ // actually generate the thumbnail.
+ $handler = $file->getHandler();
+
+ // Based on UploadStash::parseKey
+ $fileNamePos = strrpos( $thumbname, $params['f'] );
+ if ( $fileNamePos === false ) {
+ // Maybe using a short filename? (see FileRepo::nameForThumb)
+ $fileNamePos = strrpos( $thumbname, 'thumbnail' );
+ }
+
+ if ( $handler && $fileNamePos !== false ) {
+ $paramString = substr( $thumbname, 0, $fileNamePos - 1 );
+ $extraParams = $handler->parseParamString( $paramString );
+ if ( $extraParams !== false ) {
+ return $params + $extraParams;
+ }
+ }
+
+ // As a last ditch fallback, use the traditional common parameters
+ if ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) {