Made very important preview message more obvious
[lhc/web/wiklou.git] / thumb.php
index 73d2ca9..0183c3f 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -12,6 +12,9 @@ $wgNoOutputBuffer = true;
 require_once( './includes/Defines.php' );
 require_once( './LocalSettings.php' );
 require_once( 'GlobalFunctions.php' );
+
+$wgTrivialMimeDetection = true; //don't use fancy mime detection, just check the file extension for jpg/gif/png.
+
 require_once( 'Image.php' );
 require_once( 'StreamFile.php' );
 
@@ -25,6 +28,8 @@ if ( get_magic_quotes_gpc() ) {
        $width = $_REQUEST['w'];
 }
 
+$pre_render= isset($_REQUEST['r']) && $_REQUEST['r']!="0";
+
 // Some basic input validation
 
 $width = intval( $width );
@@ -34,7 +39,7 @@ $fileName = strtr( $fileName, '\\/', '__' );
 
 $imagePath = wfImageDir( $fileName ) . '/' . $fileName;
 $thumbName = "{$width}px-$fileName";
-if ( preg_match( '/\.svg$/', $fileName ) ) {
+if ( $pre_render ) {
        $thumbName .= '.png';
 }
 $thumbPath = wfImageThumbDir( $fileName ) . '/' . $thumbName;
@@ -46,6 +51,7 @@ if ( file_exists( $thumbPath ) && filemtime( $thumbPath ) >= filemtime( $imagePa
 
 // OK, no valid thumbnail, time to get out the heavy machinery
 require_once( 'Setup.php' );
+wfProfileIn( 'thumb.php' );
 
 $img = Image::newFromName( $fileName );
 if ( $img ) {
@@ -67,5 +73,7 @@ if ( $thumb && $thumb->path ) {
 </body></html>";
 }
 
+wfProfileOut( 'thumb.php' );
+
 
 ?>