Index: trunk/extensions/VipsScaler/SpecialVipsTest.php |
— | — | @@ -20,7 +20,34 @@ |
21 | 21 | } |
22 | 22 | |
23 | 23 | protected function showThumbnails() { |
| 24 | + $request = $this->getRequest(); |
24 | 25 | |
| 26 | + $title = Title::makeTitleSafe( NS_FILE, $request->getText( 'file' ) ); |
| 27 | + if ( is_null( $title ) ) { |
| 28 | + $this->getOutput()->addWikiMsg( 'vips-invalid-file' ); |
| 29 | + return; |
| 30 | + } |
| 31 | + $file = wfFindFile( $title ); |
| 32 | + if ( !$file || !$file->exists() ) { |
| 33 | + $this->getOutput()->addWikiMsg( 'vips-invalid-file' ); |
| 34 | + return; |
| 35 | + } |
| 36 | + |
| 37 | + $width = $request->getInt( 'width' ); |
| 38 | + if ( !$width ) { |
| 39 | + $this->getOutput()->addWikiMsg( 'vips-invalid-width' ); |
| 40 | + return; |
| 41 | + } |
| 42 | + |
| 43 | + $params = array( 'width' => $width ); |
| 44 | + $thumb = $file->transform( $params ); |
| 45 | + if ( !$thumb || $thumb->isError() ) { |
| 46 | + $this->getOutput()->addWikiMsg( 'vips-thumb-error' ); |
| 47 | + } |
| 48 | + |
| 49 | + $vipsThumbUrl = $this->makeUrl( $file, $width ); |
| 50 | + |
| 51 | + |
25 | 52 | } |
26 | 53 | |
27 | 54 | protected function showForm() { |
— | — | @@ -113,7 +140,7 @@ |
114 | 141 | $status = $req->execute(); |
115 | 142 | if ( $status->isOk() ) { |
116 | 143 | # Disable output and stream the file |
117 | | - $this->getContext()->getOutput()->disable(); |
| 144 | + $this->getOutput()->disable(); |
118 | 145 | print 'Content-Type: ' . $file->getMimeType() . "\r\n"; |
119 | 146 | print 'Content-Length: ' . strlen( $req->getContent() ) . "\r\n"; |
120 | 147 | print "\r\n"; |