From 9f4792d3ba09b814db600e37e5846e5d091054bb Mon Sep 17 00:00:00 2001 From: Jens Frank Date: Mon, 9 Feb 2004 00:37:06 +0000 Subject: [PATCH] Fix bug with md5 generation of archived images --- includes/GlobalFunctions.php | 17 ++++++++++++++++- includes/Skin.php | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c4788955a6..b9e9e2bbef 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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; diff --git a/includes/Skin.php b/includes/Skin.php index 3ef1ca64ac..598181ec48 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -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) ) ) { -- 2.20.1