Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Manual:Hooks/LinkerMakeMediaLinkFile

From mediawiki.org
<Manual:Hooks
LinkerMakeMediaLinkFile
Available fromversion 1.23.0
Called before the HTML for media link is returned, used for modifying media link HTML
Define function:
publicstaticfunctiononLinkerMakeMediaLinkFile($title,$file,&$html,&$attribs,&$ret){...}
Attach hook:Inextension.json:
{"Hooks":{"LinkerMakeMediaLinkFile":"MediaWiki\\Extension\\MyExtension\\Hooks::onLinkerMakeMediaLinkFile"}}
Called from:File(s):Linker.php
Interface:LinkerMakeMediaLinkFileHook.php

For more information about attaching hooks, seeManual:Hooks.
For examples of extensions using this hook, seeCategory:LinkerMakeMediaLinkFile extensions.


Details

[edit]
  • $title: The Title object associated with the file.
  • $file: The File object or false if it doesn't exist yet.
  • &$html: Pre-sanitized HTML that goes inside the anchor tag.
  • &$attribs: Link attributes.
  • &$ret: The link HTML if you choose to override the default. Default is an empty string.

You need to returnfalse if you want to modify the HTML of media links, returningtrue will produce the normal media link HTML, regardless of if$ret is set to something. Please note that you will need to include all parts of the HTML in$ret, including the<a> tag, if you choose to returnfalse.

Retrieved from "https://www.mediawiki.org/w/index.php?title=Manual:Hooks/LinkerMakeMediaLinkFile&oldid=4441077"
Categories:

[8]ページ先頭

©2009-2025 Movatter.jp