r21650 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21649‎ | r21650 | r21651 >
Date:09:17, 27 April 2007
Author:tstarling
Status:old
Tags:
Comment:
Restored previous interface for thumbUrl(), for backwards compatibility. Fixed squid purging of thumbnails in Image::purgeCache(), broken since r21411.
Modified paths:
  • /trunk/phase3/includes/Image.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Image.php
@@ -764,7 +764,7 @@
765765 * @todo document
766766 * @private
767767 */
768 - function thumbUrl( $thumbName ) {
 768+ function thumbUrlFromName( $thumbName, $subdir = 'thumb' ) {
769769 global $wgUploadPath, $wgUploadBaseUrl, $wgSharedUploadPath;
770770 if($this->fromSharedDirectory) {
771771 $base = '';
@@ -774,15 +774,27 @@
775775 $path = $wgUploadPath;
776776 }
777777 if ( Image::isHashed( $this->fromSharedDirectory ) ) {
778 - $subdir = wfGetHashPath($this->name, $this->fromSharedDirectory) .
 778+ $hashdir = wfGetHashPath($this->name, $this->fromSharedDirectory) .
779779 wfUrlencode( $this->name );
780780 } else {
781 - $subdir = '';
 781+ $hashdir = '';
782782 }
783 - $url = "{$base}{$path}/thumb{$subdir}/" . wfUrlencode( $thumbName );
 783+ $url = "{$base}{$path}/{$subdir}{$hashdir}/" . wfUrlencode( $thumbName );
784784 return $url;
785785 }
786786
 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+
787799 function getTransformScript() {
788800 global $wgSharedThumbnailScriptPath, $wgThumbnailScriptPath;
789801 if ( $this->fromSharedDirectory ) {
@@ -915,7 +927,7 @@
916928 list( $thumbExt, $thumbMime ) = self::getThumbType( $this->extension, $this->mime );
917929 $thumbName = $this->thumbName( $normalisedParams );
918930 $thumbPath = wfImageThumbDir( $this->name, $this->fromSharedDirectory ) . "/$thumbName";
919 - $thumbUrl = $this->thumbUrl( $thumbName );
 931+ $thumbUrl = $this->thumbUrlFromName( $thumbName );
920932
921933 $this->migrateThumbFile( $thumbName );
922934
@@ -1063,8 +1075,8 @@
10641076 $urls = array();
10651077 foreach ( $files as $file ) {
10661078 $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 );
10691081 $urls[] = $url;
10701082 @unlink( "$dir/$file" );
10711083 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r21411* Introduced media handler modules for file-type specific operations: thumbna...tstarling12:31, 20 April 2007