1

To offer a mobile version of an existing mediawiki installation I was looking for a practicable way to remove all images from output. The most preferred solution would be one where the generated html would no longer contain the image-tags. As I was not able to figure out a clean solution I moved the images to a different server and disabled $wgForeignFileRepos and $wgAllowExternalImages in this version. Unfortunately - while the images are not shown - there appears a placeholder box containing the image's name and a (now not functioning) link to it.

Do you know about a way to get rid of the images without using css/js or a way to bring my approach to completion?

svick
  • 236,525
  • 50
  • 385
  • 514
andi
  • 11
  • 1

2 Answers2

0

You could use this javascript mobile browswer detection and then on detection it runs the following javascript code.

var imagesremove = document.getElementsByTag('img')
imagesremove.parentNode.removeChild(imagesremove);
udonsoup16
  • 27
  • 9
0

There are probably better solutions, but you can override the ImageBeforeProduceHTML hook to make images generate empty output:

$wgHooks['ImageBeforeProduceHTML'][] = function( &$skin, &$title, &$file, &$frameParams, &$handlerParams, &$time, &$res ) {
    $res = '';
    return false;
}

...or something more fancy, such as returning a link to the image instead of an actual <img> tag.

Depending on your wiki's caching settings, you might have to purge the page cache afterwards, e.g. by setting $wgCacheEpoch.

Tgr
  • 27,442
  • 12
  • 81
  • 118