Difference between revisions of "Cropimage"
From Sega Retro
(21 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | <includeonly><div style="{{#if: {{{float|}}} |float:{{{float}}}; |}}display:inline-block; overflow:hidden; width:{{#if: {{{width|}}} |{{{width}}}px|auto}}; height:{{#if: {{{height|}}} |{{{height}}}px|auto}}"><div style="position:relative; top:-{{{y|0}}}px; left:-{{{x|0}}}px; width:{{#mediawidth:{{{image|}}}}}px; height:{{#mediaheight:{{{image|}}}}}px;">{{#if: {{{image|}}} | | + | <includeonly>{{#if:{{{scale|}}}|{{#vardefine:scale|{{{scale}}}}}|{{#vardefine:scale|1}}}}<div style=" |
+ | {{#if: {{{float|}}} | float:{{{float}}}; |}} | ||
+ | {{#if: {{{sprite|}}} | vertical-align: middle; |}} | ||
+ | display:inline-block; | ||
+ | overflow:hidden; | ||
+ | width:{{#if: {{{width|}}} |{{#expr:{{{width}}}*{{#var:scale}}}}px|auto}}; | ||
+ | height:{{#if: {{{height|}}} |{{#expr:{{{height}}}*{{#var:scale}}}}px|auto}}; | ||
+ | line-height:0px"><div style=" | ||
+ | {{#if: {{{sprite|}}} | image-rendering:pixelated; |}} | ||
+ | position:relative; | ||
+ | top:-{{#expr:{{#if:{{{y|}}}|{{{y}}}|0}}*{{#var:scale}}}}px; | ||
+ | left:-{{#expr:{{#if:{{{x|}}}|{{{x}}}|0}}*{{#var:scale}}}}px; | ||
+ | width:{{#expr:{{#mediawidth:{{{image|}}}}}*{{#var:scale}}}}px; | ||
+ | height:{{#expr:{{#mediaheight:{{{image|}}}}}*{{#var:scale}}}}px; | ||
+ | line-height:0px">{{#if: {{{image|}}} |{{scaleimage|{{{image}}}|{{#var:scale}}|nolink=true}}|No image to display.}}</div></div></includeonly><noinclude> | ||
This template will display part of an image. | This template will display part of an image. | ||
Line 11: | Line 25: | ||
| y= | | y= | ||
| float= | | float= | ||
+ | | scale= | ||
+ | | sprite= | ||
}} | }} | ||
</pre> | </pre> | ||
Line 18: | Line 34: | ||
* "x" and "y" are distances from the left and top edges of the image where the visible area begins. | * "x" and "y" are distances from the left and top edges of the image where the visible area begins. | ||
* "float" can be left or right. | * "float" can be left or right. | ||
+ | * "scale" enlarges or shrinks the image by that factor (i.e. 2 will double the image size). | ||
+ | * "sprite=yes" disables filtering. | ||
− | [[Category: | + | [[Category:Templates]] |
Latest revision as of 11:42, 17 June 2022
This template will display part of an image.
Usage
{{cropimage | image= | width= | height= | x= | y= | float= | scale= | sprite= }}
- All parameters are optional except "image".
- "width" and "height" refer to the crop area (the area of the image which remains visible), not the size of the image itself. The image is not resized.
- "x" and "y" are distances from the left and top edges of the image where the visible area begins.
- "float" can be left or right.
- "scale" enlarges or shrinks the image by that factor (i.e. 2 will double the image size).
- "sprite=yes" disables filtering.