function getSize()
{
$st = stat( $this->getImagePath() );
- return $st['size'];
+ if( $st ) {
+ return $st['size'];
+ } else {
+ return false;
+ }
}
/**
function getFullPath( $fromSharedRepository = false )
{
global $wgUploadDirectory, $wgSharedUploadDirectory;
-
+ global $wgHashedUploadDirectory, $wgHashedSharedUploadDirectory;
+
$dir = $fromSharedRepository ? $wgSharedUploadDirectory :
$wgUploadDirectory;
$ishashed = $fromSharedRepository ? $wgHashedSharedUploadDirectory :
$url = $this->img->getViewURL();
$anchoropen = '';
$anchorclose = '';
- if ( $wgUseImageResize && $wgUser->getOption( 'imagesize' ) != '' ) {
- $max = $wgImageLimits[ intval( $wgUser->getOption( 'imagesize' ) ) ];
+ if ( $wgUseImageResize ) {
+ if( $wgUser->getOption( 'imagesize' ) == '' ) {
+ $sizeSel = User::getDefaultOption( 'imagesize' );
+ } else {
+ $sizeSel = IntVal( $wgUser->getOption( 'imagesize' ) );
+ }
+ if( !isset( $wgImageLimits[$sizeSel] ) ) {
+ $sizeSel = User::getDefaultOption( 'imagesize' );
+ }
+ $max = $wgImageLimits[$sizeSel];
$maxWidth = $max[0];
$maxHeight = $max[1];
}
* a language object.
*/
function loadDefaultFromLanguage(){
- $fname = 'User::loadDefaultFromLanguage';
- wfProfileIn( $fname );
-
+ $this->mOptions = User::getDefaultOptions();
+ }
+
+ /**
+ * Combine the language default options with any site-specific options
+ * and add the default language variants.
+ *
+ * @return array
+ * @static
+ * @access private
+ */
+ function getDefaultOptions() {
/**
* Site defaults will override the global/language defaults
*/
$defOpt['variant'] = $variant;
$defOpt['language'] = $variant;
- $this->mOptions = $defOpt;
-
- wfProfileOut();
+ return $defOpt;
+ }
+
+ /**
+ * Get a given default option value.
+ *
+ * @param string $opt
+ * @return string
+ * @static
+ * @access public
+ */
+ function getDefaultOption( $opt ) {
+ $defOpts = User::getDefaultOptions();
+ if( isset( $defOpts[$opt] ) ) {
+ return $defOpts[$opt];
+ } else {
+ return '';
+ }
}
/**