Index: trunk/phase3/thumb.php |
— | — | @@ -271,7 +271,6 @@ |
272 | 272 | } |
273 | 273 | |
274 | 274 | // Check if the parameters can be extracted from the thumbnail name... |
275 | | - // @TODO: remove 'page' stuff and make ProofreadPage handle it via hook. |
276 | 275 | if ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) { |
277 | 276 | list( /* all */, $pagefull, $pagenum, $size ) = $matches; |
278 | 277 | $params['width'] = $size; |
Index: trunk/extensions/OggHandler/OggHandler.php |
— | — | @@ -30,6 +30,8 @@ |
31 | 31 | $wgExtensionMessagesFiles['OggHandlerMagic'] = "$oggDir/OggHandler.i18n.magic.php"; |
32 | 32 | $wgParserOutputHooks['OggHandler'] = array( 'OggHandler', 'outputHook' ); |
33 | 33 | |
| 34 | +$wgHooks['ExtractThumbParameters'][] = 'OggHandler::onExtractThumbParameters'; |
| 35 | + |
34 | 36 | $wgExtensionCredits['media'][] = array( |
35 | 37 | 'path' => __FILE__, |
36 | 38 | 'name' => 'OggHandler', |
Index: trunk/extensions/OggHandler/OggHandler_body.php |
— | — | @@ -510,6 +510,28 @@ |
511 | 511 | $instance->setHeaders( $outputPage ); |
512 | 512 | } |
513 | 513 | } |
| 514 | + |
| 515 | + /** |
| 516 | + * Handler for the ExtractThumbParameters hook |
| 517 | + * |
| 518 | + * @param $thumbname string URL-decoded basename of URI |
| 519 | + * @param &$params Array Currently parsed thumbnail params |
| 520 | + */ |
| 521 | + public static function onExtractThumbParameters( $thumbname, array &$params ) { |
| 522 | + if ( !preg_match( '/\.(?:ogg|ogv|oga)$/i', $params['f'] ) ) { |
| 523 | + return true; // not an ogg file |
| 524 | + } |
| 525 | + // Check if the parameters can be extracted from the thumbnail name... |
| 526 | + if ( preg_match( '!^(mid|seek=[0-9.]+)-[^/]*$!', $thumbname, $m ) ) { |
| 527 | + list( /* all */, $timeFull ) = $m; |
| 528 | + if ( $timeFull != 'mid' ) { |
| 529 | + list( $seek, $thumbtime ) = explode( '=', $timeFull, 2 ); |
| 530 | + $params['thumbtime'] = $thumbtime; |
| 531 | + } |
| 532 | + return false; // valid thumbnail URL |
| 533 | + } |
| 534 | + return true; // pass through to next handler |
| 535 | + } |
514 | 536 | } |
515 | 537 | |
516 | 538 | class OggTransformOutput extends MediaTransformOutput { |
Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler_body.php |
— | — | @@ -697,4 +697,25 @@ |
698 | 698 | $data = $this->getMetaArray( $image ); |
699 | 699 | return PagedTiffImage::getPageSize( $data, $page ); |
700 | 700 | } |
| 701 | + |
| 702 | + /** |
| 703 | + * Handler for the ExtractThumbParameters hook |
| 704 | + * |
| 705 | + * @param $thumbname string URL-decoded basename of URI |
| 706 | + * @param &$params Array Currently parsed thumbnail params |
| 707 | + */ |
| 708 | + public static function onExtractThumbParameters( $thumbname, array &$params ) { |
| 709 | + if ( !preg_match( '/\.(?:tiff|tif)$/i', $params['f'] ) ) { |
| 710 | + return true; // not an tiff file |
| 711 | + } |
| 712 | + // Check if the parameters can be extracted from the thumbnail name... |
| 713 | + if ( preg_match( '!^(lossy|lossless)-page(\d+)-(\d+)px-[^/]*$!', $thumbname, $m ) ) { |
| 714 | + list( /* all */, $lossy, $pagenum, $size ) = $matches; |
| 715 | + $params['lossy'] = $lossy; |
| 716 | + $params['width'] = $size; |
| 717 | + $params['page'] = $pagenum; |
| 718 | + return false; // valid thumbnail URL |
| 719 | + } |
| 720 | + return true; // pass through to next handler |
| 721 | + } |
701 | 722 | } |
Index: trunk/extensions/PagedTiffHandler/PagedTiffHandler.php |
— | — | @@ -130,3 +130,5 @@ |
131 | 131 | //$wgHooks['PagedTiffHandlerRenderCommand'][] = 'PagedTiffHandler::renderCommand'; |
132 | 132 | //$wgHooks['PagedTiffHandlerTiffData'][] = 'PagedTiffImage::tiffData'; |
133 | 133 | //$wgHooks['PagedTiffHandlerExifData'][] = 'PagedTiffImage::exifData'; |
| 134 | + |
| 135 | +$wgHooks['ExtractThumbParameters'][] = 'PagedTiffHandler::onExtractThumbParameters'; |