mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-23 15:57:10 +00:00
Add wgPortableInfoboxUseFileDescriptionPage (#122)
Fixes #111 Co-authored-by: BlankEclair <blankeclair@waifu.club>
This commit is contained in:
parent
2d964bca4f
commit
1c52d83867
|
@ -21,6 +21,7 @@ You can use several variables to modify extension's behaviour:
|
|||
- `$wgPortableInfoboxUseHeadings` (bool) - use heading tags for infobox titles and group headers, it may cause incompatibilities with other extensions. (default: true)
|
||||
- `$wgPortableInfoboxUseTidy` (bool) - use [RemexHtml](https://www.mediawiki.org/wiki/RemexHtml) for validating HTML in infoboxes (default: true)
|
||||
- `$wgPortableInfoboxResponsiblyOpenCollapsed` (bool) - open collapsed groups when the screen is narrow. (default: true)
|
||||
- `$wgPortableInfoboxUseFileDescriptionPage` (bool) - control whether or not embedded images in the infobox will link to their file description page instead of directly to the file. (default: false)
|
||||
|
||||
## Usage
|
||||
See: https://community.fandom.com/wiki/Help:Infoboxes
|
||||
|
|
|
@ -34,6 +34,9 @@
|
|||
},
|
||||
"PortableInfoboxResponsiblyOpenCollapsed": {
|
||||
"value": true
|
||||
},
|
||||
"PortableInfoboxUseFileDescriptionPage": {
|
||||
"value": false
|
||||
}
|
||||
},
|
||||
"MessagesDirs": {
|
||||
|
|
|
@ -152,7 +152,7 @@ class NodeMedia extends Node {
|
|||
|
||||
$mediatype = $fileObj->getMediaType();
|
||||
$image = [
|
||||
'url' => $this->resolveImageUrl( $fileObj ),
|
||||
'url' => $this->resolveImageUrl( $fileObj, $titleObj ),
|
||||
'name' => $titleObj ? $titleObj->getText() : '',
|
||||
'alt' => $alt ?? ( $titleObj ? $titleObj->getText() : null ),
|
||||
'caption' => $caption ?: null,
|
||||
|
@ -225,9 +225,16 @@ class NodeMedia extends Node {
|
|||
/**
|
||||
* Returns image url for given image title
|
||||
* @param File|null $file
|
||||
* @param Title|null $title
|
||||
* @return string url or '' if image doesn't exist
|
||||
*/
|
||||
public function resolveImageUrl( $file ) {
|
||||
public function resolveImageUrl( $file, $title ) {
|
||||
global $wgPortableInfoboxUseFileDescriptionPage;
|
||||
|
||||
if ( $wgPortableInfoboxUseFileDescriptionPage && $title ) {
|
||||
return $title->getLocalURL();
|
||||
}
|
||||
|
||||
return $file ? $file->getUrl() : '';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue