Page MenuHomePhabricator

Fix $this->file hard dependency on PageImages extension
Closed, ResolvedPublic


If a file is given, whether or not the PageImages extension is installed, use the given file. Except there is no file and there is a page images extension installed, use PageImages to generate and set $this->file.

So if all conditions above fail, just return false as the default.

Event Timeline

xSavitar triaged this task as Medium priority.Nov 17 2018, 4:13 PM
xSavitar created this task.
xSavitar moved this task from Backlog to Doing [WIP] on the User-xSavitar board.

Change 474472 had a related patch set uploaded (by D3r1ck01; owner: Alangi Derick):
[mediawiki/extensions/MobileFrontend@master] Fix $this->file hard dependency on PageImages extension

So we've got a patch up to fix the hard dependency issue :), let's see how it goes, I'll continue with the parent patch that will depend on this :)

Finally tracked it down, this is the code causing us problems @Jdlrobson

if ( $this->usePageImages ) {
	$file = $this->file;
	if ( $file ) {
		$thumb = $file->transform( [ 'width' => $size ] );
		if ( $thumb && $thumb->getUrl() ) {
			$className = 'list-thumb ';
			$className .= $thumb->getWidth() > $thumb->getHeight()
				? 'list-thumb-y'
				: 'list-thumb-x';
			$props = [
				'class' => $className,

			$imgUrl = wfExpandUrl( $thumb->getUrl(), PROTO_CURRENT );
			if ( $useBackgroundImage ) {
				$props['style'] = 'background-image: url("' . wfExpandUrl( $imgUrl, PROTO_CURRENT ) . '")';
				$text = '';
			} else {
				$props['src'] = $imgUrl;
				$text = $this->title->getText();
			$imageHtml = Html::element( $useBackgroundImage ? 'div' : 'img', $props, $text );

It's in MobilePage and that code only runs when the PageImages is installed as it checks if ( $this->usePageImages ). Why so? I mean if a file is given, then do it as we mustn't have PI installed, changing that code now to complete the pending patch for this issue :), wow

Change 474472 abandoned by D3r1ck01:
Fix $this->file hard dependency on PageImages extension

In favor of I6b40dfd8ed2403f1e0d4c4410d31356ea2493916.