Fix bug with md5 generation of archived images
authorJens Frank <jeluf@users.mediawiki.org>
Mon, 9 Feb 2004 00:37:06 +0000 (00:37 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Mon, 9 Feb 2004 00:37:06 +0000 (00:37 +0000)
includes/GlobalFunctions.php
includes/Skin.php

index c478895..b9e9e2b 100644 (file)
@@ -132,7 +132,7 @@ function wfThumbUrl( $img )
 }
 
 
-function wfImageArchiveUrl( $name, $subdir="archive" )
+function wfImageThumbUrl( $name, $subdir="thumb" )
 {
        global $wgUploadPath;
 
@@ -142,6 +142,16 @@ function wfImageArchiveUrl( $name, $subdir="archive" )
        return wfUrlencode($url);
 }
 
+function wfImageArchiveUrl( $name )
+{
+       global $wgUploadPath;
+
+       $hash = md5( substr( $name, 15) );
+       $url = "{$wgUploadPath}/archive/" . $hash{0} . "/" .
+         substr( $hash, 0, 2 ) . "/{$name}";
+       return wfUrlencode($url);
+}
+
 function wfUrlencode ( $s )
 {
        $ulink = urlencode( $s );
@@ -462,6 +472,11 @@ function wfImageDir( $fname )
        return $dest;
 }
 
+function wfImageThumbDir( $fname , $subdir="thumb")
+{
+       return wfImageArchiveDir( $fname, $subdir );
+}
+
 function wfImageArchiveDir( $fname , $subdir="archive")
 {
        global $wgUploadDirectory;
index 3ef1ca6..598181e 100644 (file)
@@ -1519,8 +1519,8 @@ class Skin {
                global $wgUseImageMagick;
                $imgPath   = wfImagePath( $name );
                $thumbName = $width."px-".$icon.$name;
-               $thumbPath = wfImageArchiveDir( $thumbName, "thumb" )."/".$thumbName;
-               $thumbUrl  = wfImageArchiveUrl( $thumbName, "thumb" );
+               $thumbPath = wfImageThumbDir( $thumbName )."/".$thumbName;
+               $thumbUrl  = wfImageThumbUrl( $thumbName );
 
                if (     (! file_exists( $thumbPath ) && file_exists( $imgPath )) 
                     ||  ( filemtime($thumbPath) < filemtime($imgPath) ) ) {