| Index: trunk/phase3/docs/hooks.txt |
| — | — | @@ -578,6 +578,13 @@ |
| 579 | 579 | &$parser: Parser object |
| 580 | 580 | &$ig: ImageGallery object |
| 581 | 581 | |
| | 582 | +'BitmapHandlerTransform': before a file is transformed, gives extension the |
| | 583 | +possibility to transform it themselves |
| | 584 | +$handler: BitmapHandler |
| | 585 | +$image: File |
| | 586 | +&$scalerParams: Array with scaler parameters |
| | 587 | +&$mto: null, set to a MediaTransformOutput |
| | 588 | + |
| 582 | 589 | 'BlockIp': before an IP address or user is blocked |
| 583 | 590 | $block: the Block object about to be saved |
| 584 | 591 | $user: the user _doing_ the block (not the one being blocked) |
| Index: trunk/phase3/includes/media/Bitmap.php |
| — | — | @@ -101,6 +101,7 @@ |
| 102 | 102 | 'mimeType' => $image->getMimeType(), |
| 103 | 103 | 'srcPath' => $image->getPath(), |
| 104 | 104 | 'dstPath' => $dstPath, |
| | 105 | + 'dstUrl' => $dstUrl, |
| 105 | 106 | ); |
| 106 | 107 | |
| 107 | 108 | wfDebug( __METHOD__ . ": creating {$scalerParams['physicalDimensions']} thumbnail at $dstPath\n" ); |
| — | — | @@ -135,8 +136,20 @@ |
| 136 | 137 | wfDebug( __METHOD__ . ": Unable to create thumbnail destination directory, falling back to client scaling\n" ); |
| 137 | 138 | return $this->getClientScalingThumbnailImage( $image, $scalerParams ); |
| 138 | 139 | } |
| 139 | | - |
| | 140 | + |
| | 141 | + # Try a hook |
| | 142 | + $mto = null; |
| | 143 | + wfRunHooks( 'BitmapHandlerTransform', array( $this, $image, &$scalerParams, &$mto ) ); |
| | 144 | + if ( !is_null( $mto ) ) { |
| | 145 | + wfDebug( __METHOD__ . ": Hook to BitmapHandlerTransform created an mto\n" ); |
| | 146 | + $scaler = 'hookaborted'; |
| | 147 | + } |
| | 148 | + |
| 140 | 149 | switch ( $scaler ) { |
| | 150 | + case 'hookaborted': |
| | 151 | + # Handled by the hook above |
| | 152 | + $err = $mto->isError() ? $mto : false; |
| | 153 | + break; |
| 141 | 154 | case 'im': |
| 142 | 155 | $err = $this->transformImageMagick( $image, $scalerParams ); |
| 143 | 156 | break; |
| — | — | @@ -161,6 +174,8 @@ |
| 162 | 175 | # Thumbnail was zero-byte and had to be removed |
| 163 | 176 | return new MediaTransformError( 'thumbnail_error', |
| 164 | 177 | $scalerParams['clientWidth'], $scalerParams['clientHeight'] ); |
| | 178 | + } elseif ( $mto ) { |
| | 179 | + return $mto; |
| 165 | 180 | } else { |
| 166 | 181 | return new ThumbnailImage( $image, $dstUrl, $scalerParams['clientWidth'], |
| 167 | 182 | $scalerParams['clientHeight'], $dstPath ); |
| — | — | @@ -443,7 +458,7 @@ |
| 444 | 459 | * @param $errMsg string Error message |
| 445 | 460 | * @return MediaTransformError |
| 446 | 461 | */ |
| 447 | | - protected function getMediaTransformError( $params, $errMsg ) { |
| | 462 | + public function getMediaTransformError( $params, $errMsg ) { |
| 448 | 463 | return new MediaTransformError( 'thumbnail_error', $params['clientWidth'], |
| 449 | 464 | $params['clientHeight'], $errMsg ); |
| 450 | 465 | } |
| Index: trunk/phase3/RELEASE-NOTES |
| — | — | @@ -116,6 +116,8 @@ |
| 117 | 117 | file description page. The sizes are set by $wgImageLimits. |
| 118 | 118 | * (bug 28031) Add pageCount support to ArchivedFile |
| 119 | 119 | * (bug 27924) PhpHttpRequest doesn't return response body if HTTP != 200 |
| | 120 | +* Added hook BitmapHandlerTransform to allow extension to transform a file |
| | 121 | + without overriding the entire handler. |
| 120 | 122 | |
| 121 | 123 | === Bug fixes in 1.18 === |
| 122 | 124 | * (bug 23119) WikiError class and subclasses are now marked as deprecated |