FANDOM


  • Hello, I'm new here, so I'm not sure if this is the correct place to ask this. But the wiki I use has a fairly complex template that we want to change a part of, and I was wondering if there was any place I could find an expert on this stuff?

      Loading editor
    • Please include a link. People can’t determine whether they’re experts without it. Is it LUA? Tables? Parser functions? js? A combo?

        Loading editor
    • Yeah, good point. https://mcleodgaming.fandom.com/wiki/Template:Multiple_image



      Basically, it's a design template that lets us insert multiple images into a single box. The way it's set up, we can set every image in that box to the same width, but we don't know how to make it work with height instead.

        Loading editor
    • Well, it would be similar logic just using the height portion of the image syntax's size parameter.

      Original:
      
      [[File:Wiki-wordmark.png]]
      
      Scaled to width less than or equal to 50px:
      
      [[File:Wiki-wordmark.png|50px]]
      
      Scaled to height less than or equal to 50px:
      
      [[File:Wiki-wordmark.png|x50px]]
      
      Scaled to width and height both less than or equal to 50px:
      
      [[File:Wiki-wordmark.png|50x50px]]
      

      Original:

      Wiki-wordmark

      Scaled to width less than or equal to 50px:

      Wiki-wordmark

      Scaled to height less than or equal to 50px:

      Wiki-wordmark

      Scaled to width and height both less than or equal to 50px:

      Wiki-wordmark

        Loading editor
    • I'm using a test template to try it and make something work, but I'm not having any luck. I'm really not an expert at this stuff, but trying to use the test template on a page it gives me "Expression error: Unrecognised word "x"" every time.

        Loading editor
    • It would help if you had a test page we could view the results on.

        Loading editor
    • Sorry for the wait, but I'm not exactly sure what kinds of results I should be putting on for a test page. But I was able to use the wiki's Sandbox page to display the template and how it works.

      https://mcleodgaming.fandom.com/wiki/McLeodGaming_Wiki:Sandbox

        Loading editor
    • Okay. Clearly I didn't explain very well. The current template takes in the direction: horizontal or vertical. If it is versatile, it doesn't do much. If it is horizontal, it does a bunch of calculations based on the width parameters. Then it uses the values of the width parameters to set the width of the images.

      What you need to make the image the same height in the vertical layout is to have a similar process to the horizontal layout but using a height parameter instead of a width parameter. When the template gets to the part about specifying the image size, that is when the "x" comes in.

      Does that make more sense?

        Loading editor
    • Yeah, I see what you're saying, looking at the code I can see that's how it works. But I never wanted to make it the same height in the vertical layout, if anything that creates a new problem. My problem is that the horizontal layout uses width perimeters to begin with, and I want height. And I haven't been having much luck trying to correct that.

        Loading editor
    • Okay, so what you are saying is your want to have a horizontal layout where all the images are the same height, not the same width; correct? Do you want to keep the option to have the same widths? If not, just rename all the "width" parameters to "height" parameters and then place an "x" in front of the calculated value to get the image syntax to set the height instead of the width.

        Loading editor
    • So for Wikitext image sizing, something like 200px will try to set the width to 200px and maintain the aspect ratio, x50px will try to set the height to 50px and maintain the aspect ratio, and 200x50px will try to set width to 200px and height to 50px.

      See Help:Images at MediaWiki.org.

        Loading editor
    • Minor correction. When setting both width and height, it will still maintain the aspect ratio. What will happen is it will use whichever is the smaller of the two. This means either the width or the height will be as specified and the other will be smaller than specified.

        Loading editor
    • Okay, I think I managed to get it down. I finally figured out where the x should go, and now I can control the height of the images rather than the width. That being said, I would in fact like to keep the option to have widths.

      Also, I think I created a new problem. By the looks of it, the widths of the images are what control the width of the template itself when horizontal, so when the width parameter is replaced with height things get messed up. In the test page I linked to before, I have the parameter set to 180, so I think the width of the template adds 180 for each image and a little extra on the sides. Images exceeding that width get pushed down, and either way they're off-center with too much extra space.

        Loading editor
    • Yes. Just as you con't determine the height when fixing the widths, you can't determine the width when fixing the heights. Therefore, setting the max-width property is likely to be inaccurate. If you want to center the images in such a case, then you need to center the enclosing div tags.

        Loading editor
    • Well using max height at least doesn't break it, but without a proper max width parameter There's way too much open space on the right side, and for some reason the gap between the pictures sometimes doesn't show up.

      Is there really no way to get the width parameters for the images, or some way to substitute for them? If I can't make the width consistent with how it was before, then this whole thing will have been for nothing.

        Loading editor
    • As long as you restrict the height of the images, there is no way to know for sure what the width will be. Similarly, if you restrict the width of the images, there is no way to know for sure what the height will be. The issue is that it depends on the individual dimensions of each image. If you could get that information, you could go through and manually calculate the result. However, as far as I know, there is no way to do that with MediaWiki alone. It might be doable with Lua but I am not sure as I have never actually used Lua and am not aware of its limitations. For sure, you should be able to do it using custom JS but that would require quite a bit of development.

        Loading editor
    • A FANDOM user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message
Community content is available under CC-BY-SA unless otherwise noted.