Jump to content

Template:ImageGrid: Difference between revisions

From Keloidpedia
No edit summary
No edit summary
 
Line 1: Line 1:
<includeonly>
<includeonly>
<div style="display:flex; flex-wrap:wrap; gap:10px; justify-content:center;">
<style>
{{#if: {{{1|}}} | [[File:{{{1}}}|150px]] }}
.imagegrid-flex {
{{#if: {{{2|}}} | [[File:{{{2}}}|150px]] }}
  display: flex;
{{#if: {{{3|}}} | [[File:{{{3}}}|150px]] }}
  flex-wrap: wrap;
{{#if: {{{4|}}} | [[File:{{{4}}}|150px]] }}
  gap: 0.5em;
{{#if: {{{5|}}} | [[File:{{{5}}}|150px]] }}
  justify-content: center;
{{#if: {{{6|}}} | [[File:{{{6}}}|150px]] }}
}
.imagegrid-flex img, .imagegrid-flex .mw-file {
  max-width: 200px;
  height: auto;
}
</style>
 
<div class="imagegrid-flex">
  {{#foreach: {{{images|}}} |-
    {{#if: {{{this|}}} |
      <!-- If it looks like a plain filename, use File: prefix; otherwise assume it's a full URL -->
      {{#ifeq: {{#strpos: {{{this}}} | https:// }} | -1 |
        <!-- no URL substring found → treat as wiki image name -->
        [[File:{{{this}}}|frameless]]
      |
        <!-- contains "https://" → embed via <img> -->
        <img src="{{{this}}}" alt="" />
      }}
    }}
  }}
</div>
</div>
</includeonly>
</includeonly>
<noinclude>
Usage:
<pre>
{{ImageGrid
| Example1.jpg
| Example2.png
| Example3.jpg
| Example4.png
| Example5.png
}}
</pre>
</noinclude>

Latest revision as of 02:30, 30 September 2025