Difference between revisions of "External Image"

From PKC
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<span class="plainlinks">[{{fullurl:MediaWiki}} http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png]</span>


http://localhost:8000/s/XKNfpS5BwKHPsaY/preview
To reference an external image and make sure it appears with a controllable parameter, one can reference this page on Stack overflow<ref>https://stackoverflow.com/questions/19450262/mediawiki-set-external-image-width-by-value</ref>.
 
The original post by stack overflow user [https://stackoverflow.com/users/82439/brion Brion] is reproduced and the template has been created here:
 
 
The first step is to add one more line in <code>LocalSettings.php</code>.
<syntaxhighlight lang=PHP>
$wgAllowExternalImages = true;
</syntaxhighlight>
 
Then, you need to have admin access to the MediaWiki site, so that you can edit the file:<code>MediaWiki:Common.css</code>.
 
In [[MediaWiki:Common.css]] add:
<syntaxhighlight lang=CSS>
.externalimage-holder {
    position: relative;
}
.externalimage-holder img {
    width: 100%;
    height: auto;
}
</syntaxhighlight>
 
Then, set up a Template in [[Template:Sized-external-image]] like this:
<syntaxhighlight lang=HTML>
<div class="externalimage-holder" style="width:{{{1}}}">{{{2}}}</div>
</syntaxhighlight>
 
Then, call it like this:
<syntaxhighlight lang=HTML>
{{sized-external-image|250px|https://storage.cloud.google.com/pub_papers/GitiFactory.png}}
</syntaxhighlight>
 
Then, it should show up as follows:
{{sized-external-image|250px|https://storage.cloud.google.com/pub_papers/GitiFactory.png}}
 
=References=
<references/>

Latest revision as of 18:28, 12 September 2021

To reference an external image and make sure it appears with a controllable parameter, one can reference this page on Stack overflow[1].

The original post by stack overflow user Brion is reproduced and the template has been created here:


The first step is to add one more line in LocalSettings.php.

$wgAllowExternalImages = true;

Then, you need to have admin access to the MediaWiki site, so that you can edit the file:MediaWiki:Common.css.

In MediaWiki:Common.css add:

.externalimage-holder {
    position: relative;
}
.externalimage-holder img {
    width: 100%;
    height: auto;
}

Then, set up a Template in Template:Sized-external-image like this:

<div class="externalimage-holder" style="width:{{{1}}}">{{{2}}}</div>

Then, call it like this:

{{sized-external-image|250px|https://storage.cloud.google.com/pub_papers/GitiFactory.png}}

Then, it should show up as follows:

References