Index: trunk/phase3/includes/Image.php |
— | — | @@ -764,7 +764,7 @@ |
765 | 765 | * @todo document |
766 | 766 | * @private |
767 | 767 | */ |
768 | | - function thumbUrl( $thumbName ) { |
| 768 | + function thumbUrlFromName( $thumbName, $subdir = 'thumb' ) { |
769 | 769 | global $wgUploadPath, $wgUploadBaseUrl, $wgSharedUploadPath; |
770 | 770 | if($this->fromSharedDirectory) { |
771 | 771 | $base = ''; |
— | — | @@ -774,15 +774,27 @@ |
775 | 775 | $path = $wgUploadPath; |
776 | 776 | } |
777 | 777 | if ( Image::isHashed( $this->fromSharedDirectory ) ) { |
778 | | - $subdir = wfGetHashPath($this->name, $this->fromSharedDirectory) . |
| 778 | + $hashdir = wfGetHashPath($this->name, $this->fromSharedDirectory) . |
779 | 779 | wfUrlencode( $this->name ); |
780 | 780 | } else { |
781 | | - $subdir = ''; |
| 781 | + $hashdir = ''; |
782 | 782 | } |
783 | | - $url = "{$base}{$path}/thumb{$subdir}/" . wfUrlencode( $thumbName ); |
| 783 | + $url = "{$base}{$path}/{$subdir}{$hashdir}/" . wfUrlencode( $thumbName ); |
784 | 784 | return $url; |
785 | 785 | } |
786 | 786 | |
| 787 | + /** |
| 788 | + * @deprecated Use $image->transform()->getUrl() or thumbUrlFromName() |
| 789 | + */ |
| 790 | + function thumbUrl( $width, $subdir = 'thumb' ) { |
| 791 | + $name = $this->thumbName( array( 'width' => $width ) ); |
| 792 | + if ( strval( $name ) !== '' ) { |
| 793 | + return $this->thumbUrlFromName( $name, $subdir ); |
| 794 | + } else { |
| 795 | + return false; |
| 796 | + } |
| 797 | + } |
| 798 | + |
787 | 799 | function getTransformScript() { |
788 | 800 | global $wgSharedThumbnailScriptPath, $wgThumbnailScriptPath; |
789 | 801 | if ( $this->fromSharedDirectory ) { |
— | — | @@ -915,7 +927,7 @@ |
916 | 928 | list( $thumbExt, $thumbMime ) = self::getThumbType( $this->extension, $this->mime ); |
917 | 929 | $thumbName = $this->thumbName( $normalisedParams ); |
918 | 930 | $thumbPath = wfImageThumbDir( $this->name, $this->fromSharedDirectory ) . "/$thumbName"; |
919 | | - $thumbUrl = $this->thumbUrl( $thumbName ); |
| 931 | + $thumbUrl = $this->thumbUrlFromName( $thumbName ); |
920 | 932 | |
921 | 933 | $this->migrateThumbFile( $thumbName ); |
922 | 934 | |
— | — | @@ -1063,8 +1075,8 @@ |
1064 | 1076 | $urls = array(); |
1065 | 1077 | foreach ( $files as $file ) { |
1066 | 1078 | $m = array(); |
1067 | | - if ( preg_match( '/^(\d+)px/', $file, $m ) ) { |
1068 | | - $url = $this->thumbUrl( $m[1] ); |
| 1079 | + if ( preg_match( '/^\d+px/', $file, $m ) ) { |
| 1080 | + $url = $this->thumbUrlFromName( $file ); |
1069 | 1081 | $urls[] = $url; |
1070 | 1082 | @unlink( "$dir/$file" ); |
1071 | 1083 | } |