}
-function wfImagePath( $img )
-{
- global $wgUploadDirectory;
-
- $nt = Title::newFromText( $img );
- if( !$nt ) return "";
-
- $name = $nt->getDBkey();
- $hash = md5( $name );
-
- $path = "{$wgUploadDirectory}/" . $hash{0} . "/" .
- substr( $hash, 0, 2 ) . "/{$name}";
- return $path;
-}
-
-function wfThumbUrl( $img )
-{
- global $wgUploadPath;
-
- $nt = Title::newFromText( $img );
- if( !$nt ) return "";
+// orphan function wfThumbUrl( $img )
+//{
+// global $wgUploadPath;
+//
+// $nt = Title::newFromText( $img );
+// if( !$nt ) return "";
+//
+// $name = $nt->getDBkey();
+// $hash = md5( $name );
+//
+// $url = "{$wgUploadPath}/thumb/" . $hash{0} . "/" .
+// substr( $hash, 0, 2 ) . "/{$name}";
+// return wfUrlencode( $url );
+//}
- $name = $nt->getDBkey();
- $hash = md5( $name );
-
- $url = "{$wgUploadPath}/thumb/" . $hash{0} . "/" .
- substr( $hash, 0, 2 ) . "/{$name}";
- return wfUrlencode( $url );
-}
-
-
-function wfImageThumbUrl( $name, $subdir="thumb" )
-{
- global $wgUploadPath;
-
- $hash = md5( $name );
- $url = "{$wgUploadPath}/{$subdir}/" . $hash{0} . "/" .
- substr( $hash, 0, 2 ) . "/{$name}";
- return wfUrlencode($url);
-}
function wfImageArchiveUrl( $name )
{
$attr; # /
+
function Image( $name )
{
$this->name = $name;
return $this->fileExists;
}
+ function thumbUrl( $width, $subdir="thumb" ) {
+ global $wgUploadPath;
+
+ $name = $this->thumbName( $width );
+ $hash = md5( $name );
+ $url = "{$wgUploadPath}/{$subdir}/" . $hash{0} . "/" . substr( $hash, 0, 2 ) . "/{$name}";
+
+ return wfUrlencode($url);
+ }
+
+ function thumbName( $width ) {
+ return $width."px-".$this->name;
+ }
function createThumb( $width ) {
global $wgUploadDirectory;
global $wgImageMagickConvertCommand;
global $wgUseImageMagick;
global $wgUseSquid, $wgInternalServer;
- $thumbName = $width."px-".$this->name;
+ $thumbName = $this->thumbName( $width );
$thumbPath = wfImageThumbDir( $thumbName )."/".$thumbName;
- $thumbUrl = wfImageThumbUrl( $thumbName );
+ $thumbUrl = $this->thumbUrl( $width );
if ( ! $this->exists() )
{
} //function createThumb
} //class
+
+// return path name of an image
+// canonicalize name.
+function wfImagePath( $imgname )
+{
+ global $wgUploadDirectory;
+
+ $nt = Title::newFromText( $imgname );
+ if( !$nt ) return "";
+
+ $name = $nt->getDBkey();
+ $hash = md5( $name );
+
+ $path = "{$wgUploadDirectory}/" . $hash{0} . "/" .
+ substr( $hash, 0, 2 ) . "/{$name}";
+ return $path;
+}
# Squid purging
if ( $wgUseSquid ) {
$urlArr = Array(
- $wgInternalServer.wfImageUrl( $image )
+ $wgInternalServer . Image::wfImageUrl( $image )
);
wfPurgeSquidServers($urlArr);
}
if ( $wgUseSquid ) {
$urlArr = Array(
$wgInternalServer.wfImageArchiveUrl( $name ),
- $wgInternalServer.wfImageUrl( $name )
+ $wgInternalServer . Image::wfImageUrl( $name )
);
wfPurgeSquidServers($urlArr);
}