PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 29, 2022

[FIXED] How do I scale an image's width to a percentage of the window with MediaWiki?

 July 29, 2022     css, html, image, mediawiki, scale     No comments   

Issue

With html I can scale an image's width to a percentage of the available window like this:

<img src=whatever.png width=50% />

With mediawiki this seems to be impossible (if you do not allow html injections). Is it really? Don't tell me I have to write a mediawiki extension ;)

Note the CSS answer from Is there a way automatically to resize MediaWiki images depending on screen size? is not a solution. I want to have different images in one page with different percentages.


Solution

It should be possible to apply the CSS solution to specific images by tagging them with a custom class name. That is, you'd add something like the following to your MediaWiki:Common.css page:

img.halfwidth {
    width: 50%;
    height: auto;
}

and then use wiki markup like this:

[[File:Myimage.jpg|class=halfwidth]]

(Note that specifying a class name on an image like this requires MediaWiki 1.20+. If, for some reason, you need to do this on an older MediaWiki version, you can instead change the CSS selector to e.g. .halfwidth img, and the wiki syntax to <div class="halfwidth">[[File:Myimage.png]]</div>.)



Answered By - Ilmari Karonen
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing