+ // Get the full file storage path and extract the source file name.
+ // (e.g. 120px-Foo.png => Foo.png or page2-120px-Foo.png => Foo.png).
+ // This only applies to thumbnails, and all thumbnails should
+ // be under a folder that has the source file name.
+ if ( strpos( $path, '/thumb/' ) === 0 ) {
+ $name = wfBaseName( dirname( $path ) ); // file is a thumbnail
+ $filename = $repo->getZonePath( 'thumb' ) . substr( $path, 6 ); // strip "/thumb"
+ } else {
+ $name = wfBaseName( $path ); // file is a source file
+ $filename = $repo->getZonePath( 'public' ) . $path;
+ }