*/
var $file;
- var $width, $height, $url, $page, $path;
+ var $width, $height, $url, $page, $path, $lang;
/**
* @var array Associative array mapping optional supplementary image files
/**
* @param $title string
- * @param $params array
+ * @param $params string|array Query parameters to add
* @return array
*/
- public function getDescLinkAttribs( $title = null, $params = '' ) {
- $query = '';
+ public function getDescLinkAttribs( $title = null, $params = array() ) {
+ if ( is_array( $params ) ) {
+ $query = $params;
+ } else {
+ $query = array();
+ }
if ( $this->page && $this->page !== 1 ) {
- $query = 'page=' . urlencode( $this->page );
+ $query['page'] = $this->page;
+ }
+ if ( $this->lang ) {
+ $query['lang'] = $this->lang;
}
- if ( $params ) {
- $query .= $query ? '&' . $params : $params;
+
+ if ( is_string( $params ) && $params !== '' ) {
+ $query = $params . '&' . wfArrayToCgi( $query );
}
+
$attribs = array(
'href' => $this->file->getTitle()->getLocalURL( $query ),
'class' => 'image',
# Previous parameters:
# $file, $url, $width, $height, $path = false, $page = false
+ $defaults = array(
+ 'page' => false,
+ 'lang' => false
+ );
+
if ( is_array( $parameters ) ) {
- $defaults = array(
- 'page' => false
- );
$actualParams = $parameters + $defaults;
} else {
# Using old format, should convert. Later a warning could be added here.
'width' => $path,
'height' => $parameters,
'page' => ( $numArgs > 5 ) ? func_get_arg( 5 ) : false
- );
+ ) + $defaults;
$path = ( $numArgs > 4 ) ? func_get_arg( 4 ) : false;
}
$this->height = round( $actualParams['height'] );
$this->page = $actualParams['page'];
+ $this->lang = $actualParams['lang'];
}
/**
* valign vertical-align property, if the output is an inline element
* img-class Class applied to the \<img\> tag, if there is such a tag
* desc-query String, description link query params
+ * override-width Override width attribute. Should generally not set
+ * override-height Override height attribute. Should generally not set
* custom-url-link Custom URL to link to
* custom-title-link Custom Title object to link to
* custom target-link Value of the target attribute, for custom-target-link
if ( !empty( $options['img-class'] ) ) {
$attribs['class'] = $options['img-class'];
}
+ if ( isset( $options['override-height'] ) ) {
+ $attribs['height'] = $options['override-height'];
+ }
+ if ( isset( $options['override-width'] ) ) {
+ $attribs['width'] = $options['override-width'];
+ }
// Additional densities for responsive images, if specified.
if ( !empty( $this->responsiveUrls ) ) {