12use InvalidArgumentException;
47 if ( is_array( $parameters ) ) {
48 $actualParams = $parameters + $defaults;
51 $numArgs = func_num_args();
54 'height' => $parameters,
55 'page' => ( $numArgs > 5 ) ? func_get_arg( 5 ) : false
57 $path = ( $numArgs > 4 ) ? func_get_arg( 4 ) :
false;
68 $this->width = (int)round( $actualParams[
'width'] );
69 $this->height = (int)round( $actualParams[
'height'] );
71 $this->page = $actualParams[
'page'];
72 $this->lang = $actualParams[
'lang'];
109 public function toHtml( $options = [] ) {
111 $mainConfig = $services->getMainConfig();
114 if ( func_num_args() === 2 ) {
115 throw new InvalidArgumentException( __METHOD__ .
' called in the old style' );
118 $query = $options[
'desc-query'] ??
'';
125 if ( isset( $options[
'alt'] ) ) {
126 $attribs[
'alt'] = $options[
'alt'];
132 isset( $options[
'magnify-resource'] ) &&
133 !( $options[
'desc-link'] ??
false )
135 $attribs[
'resource'] = $options[
'magnify-resource'];
140 'decoding' =>
'async',
143 if ( $options[
'loading'] ?? $nativeImageLazyLoading ) {
144 $attribs[
'loading'] = $options[
'loading'] ??
'lazy';
147 if ( !empty( $options[
'custom-url-link'] ) ) {
148 $linkAttribs = [
'href' => $options[
'custom-url-link'] ];
149 if ( !empty( $options[
'title'] ) ) {
150 $linkAttribs[
'title'] = $options[
'title'];
152 if ( !empty( $options[
'custom-target-link'] ) ) {
153 $linkAttribs[
'target'] = $options[
'custom-target-link'];
154 } elseif ( !empty( $options[
'parser-extlink-target'] ) ) {
155 $linkAttribs[
'target'] = $options[
'parser-extlink-target'];
157 if ( !empty( $options[
'parser-extlink-rel'] ) ) {
158 $linkAttribs[
'rel'] = $options[
'parser-extlink-rel'];
160 } elseif ( !empty( $options[
'custom-title-link'] ) ) {
162 $title = $options[
'custom-title-link'];
164 'href' => $title->getLinkURL( $options[
'custom-title-link-query'] ??
null ),
165 'title' => empty( $options[
'title'] ) ? $title->getPrefixedText() : $options[
'title']
167 } elseif ( !empty( $options[
'desc-link'] ) ) {
169 empty( $options[
'title'] ) ?
null : $options[
'title'],
172 } elseif ( !empty( $options[
'file-link'] ) ) {
173 $linkAttribs = [
'href' => $this->file->getUrl() ];
175 $linkAttribs =
false;
176 if ( !empty( $options[
'title'] ) ) {
177 $linkAttribs = [
'title' => $options[
'title'] ];
181 if ( empty( $options[
'no-dimensions'] ) ) {
185 if ( !empty( $options[
'valign'] ) ) {
186 $attribs[
'style'] =
"vertical-align: {$options['valign']}";
188 if ( !empty( $options[
'img-class'] ) ) {
189 $attribs[
'class'] = $options[
'img-class'];
191 if ( isset( $options[
'override-height'] ) ) {
192 $attribs[
'height'] = $options[
'override-height'];
194 if ( isset( $options[
'override-width'] ) ) {
195 $attribs[
'width'] = $options[
'override-width'];
205 (
new HookRunner( $services->getHookContainer() ) )
206 ->onThumbnailBeforeProduceHTML( $this, $attribs, $linkAttribs );
213class_alias( ThumbnailImage::class,
'ThumbnailImage' );
A class containing constants representing the names of configuration variables.
const NativeImageLazyLoading
Name constant for the NativeImageLazyLoading setting, for use with Config::get()