问题
MediaWiki has a great built-in way for finessing the display of images, e.g. from http://www.mediawiki.org/wiki/Help:Images :
[[File:MediaWiki:Image sample|thumb|50px]]
[[File:MediaWiki:Image sample|border|50px]]
However, unfortunately, the MediaWiki repository I have to work with has disabled image uploads.
I'm wondering if there's a way I can apply the above convenience shortcuts to an externally hosted image URL, e.g. ideal would be:
[[File:http://somewhere.com/image.jpg|thumb|50px]]
Is what I'm trying to do impossible?
回答1:
Yes, can't be done. From the MediaWiki manual:
For resizing images in mediawiki they need to have a row in image table of database containing dimensions and other information of image so you can't resize external images.
If those images have been uploaded in another mediawiki or if they are somewhere in your site and you want to let mediawiki make thumbnail of them you can set $wgUseSharedUploads to true and set $wgSharedUploadPath and $wgSharedUploadDBname instead of enabling external images.
回答2:
If client-side resizing is sufficient, you could probably whip something up with CSS...
Wrap the image you want to resize in a div or span and give it a particular class like:
<div class="image100px">http://example.com/path/to/image.jpeg</div>
And in the [[MediaWiki:Common.css]] page on the wiki add an entry like this:
.image100px img { width: 100px; }
(Note that due to caching of the CSS you might have to force a reload to see the update.)
If you need to serve out server-resized images, then the easiest way will be to just resize the images and upload them on your external server. (Alternatively you could write a MediaWiki extension that will rescale external images, but if you can't even turn on uploads this won't help you much!)
来源:https://stackoverflow.com/questions/1417201/in-mediawiki-is-there-a-way-i-can-apply-imagename-style-resizing-to-exte