* @return string
*/
function fetchImageQuery( $query ) {
- global $wgMemc;
+ global $wgMemc, $wgLanguageCode;
$query = array_merge( $query,
array(
'action' => 'query',
'redirects' => 'true'
) );
+ if ( !isset( $query['uselang'] ) ) { // uselang is unset or null
+ $query['uselang'] = $wgLanguageCode;
+ }
if ( $this->mApiBase ) {
$url = wfAppendQuery( $this->mApiBase, $query );
} else {
}
}
+ /**
+ * @param $name string
+ * @param $width int
+ * @param $height int
+ * @param $otherParams string
+ * @return bool|MediaTransformError
+ * @since 1.22
+ */
+ function getThumbError( $name, $width = -1, $height = -1, $otherParams = '', $lang = null ) {
+ $data = $this->fetchImageQuery( array(
+ 'titles' => 'File:' . $name,
+ 'iiprop' => 'url|timestamp',
+ 'iiurlwidth' => $width,
+ 'iiurlheight' => $height,
+ 'iiurlparam' => $otherParams,
+ 'prop' => 'imageinfo',
+ 'uselang' => $lang,
+ ) );
+ $info = $this->getImageInfo( $data );
+
+ if( $data && $info && isset( $info['thumberror'] ) ) {
+ wfDebug( __METHOD__ . " got remote thumb error " . $info['thumberror'] . "\n" );
+ return new MediaTransformError(
+ 'thumbnail_error_remote',
+ $width,
+ $height,
+ $this->getDisplayName(),
+ $info['thumberror'] // already parsed message from foreign repo
+ );
+ } else {
+ return false;
+ }
+ }
+
/**
* Return the imageurl from cache if possible
*
// Note, the this->canRender() check above implies
// that we have a handler, and it can do makeParamString.
$otherParams = $this->handler->makeParamString( $params );
+ $width = isset( $params['width'] ) ? $params['width'] : -1;
+ $height = isset( $params['height'] ) ? $params['height'] : -1;
$thumbUrl = $this->repo->getThumbUrlFromCache(
$this->getName(),
- isset( $params['width'] ) ? $params['width'] : -1,
- isset( $params['height'] ) ? $params['height'] : -1,
- $otherParams );
+ $width,
+ $height,
+ $otherParams
+ );
+ if ( $thumbUrl === false ) {
+ global $wgLang;
+ return $this->repo->getThumbError(
+ $this->getName(),
+ $width,
+ $height,
+ $otherParams,
+ $wgLang->getCode()
+ );
+ }
return $this->handler->getTransform( $this, 'bogus', $thumbUrl, $params );
}
'thumbnail-more' => 'Enlarge',
'filemissing' => 'File missing',
'thumbnail_error' => 'Error creating thumbnail: $1',
+'thumbnail_error_remote' => 'Error message from $1:
+$2',
'djvu_page_error' => 'DjVu page out of range',
'djvu_no_xml' => 'Unable to fetch XML for DjVu file',
'thumbnail-temp-create' => 'Unable to create temporary thumbnail file',
* {{msg-mw|Djvu page error}}
* {{msg-mw|Svg-long-error}}
* other custom string',
+'thumbnail_error_remote' => 'Message shown in a thumbnail frame when creation of the thumbnail fails. Parameters:
+* $1 - is the name of the shared repository, see {{msg-mw|shardupload}}
+* $2 - the reason, see {{msg-mw|thumbnail_error}}',
'djvu_page_error' => 'Used as error message.
See also:
'thumbnail-more',
'filemissing',
'thumbnail_error',
+ 'thumbnail_error_remote',
'djvu_page_error',
'djvu_no_xml',
'thumbnail-temp-create',