Difference between revisions of "Template:CSS image crop/doc"

From CWCki
Jump to navigation Jump to search
(importing image cropper from Wikipedia (docs))
 
m
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
 
{{tl|{{BASEPAGENAME}}}} creates a crop of an image inline for previewing the look and feel of a page, or for linking to full images when a slight crop is preferred in an article, but the full image is more encyclopedic in general. Where only a small section of the image is used after the crop, it's best to upload the crop as a new file, to avoid sending the extra image data to users.  
{{tl|{{BASEPAGENAME}}}} creates a crop of an image inline for previewing the look and feel of a page, or for linking to full images when a slight crop is preferred in an article, but the full image is more encyclopaedic in general. Where only a small section of the image is used after the crop, it's best to upload the crop as a new file, to avoid sending the extra image data to users.
 
Note: There was a previous glitch for which some people had to use "tleft" "tright" etc. as a workaround because "left" and "right" did not work. As a result, to avoid having to fix all those pages that used the workaround, the template has been designed to function properly regardless of whether tright or right is used. See template talk for details.


===Usage===
===Usage===
<pre>
<pre>
{{CSS image crop
{{CSS image crop
|Image        = The Name of the image file, or may accept {{Annotated image}}.
|Image        = The name of the image file. Don't include the 'File:' part.
|bSize        = The Base Image width in pixels (the image we are cropping on)
|bSize        = The Base Image width in pixels (the image we are cropping on)
|cWidth        = Crop Image Width in pixels
|cWidth        = Crop Image Width in pixels
Line 22: Line 19:
|Alt          = The alt text for the image.
|Alt          = The alt text for the image.
|Page          = The page of the file, if there are multiple pages (such as pdf files).
|Page          = The page of the file, if there are multiple pages (such as pdf files).
|magnify-link  = The image to be linked by the magnify icon (Use if the Image parameter is set to
                {{Annotated image}} or the Link parameter leads to something other than the image).
}}
}}
</pre>
</pre>


If you used above parameters incorrectly, then the article will be placed into [[:Category:CSS image crop using invalid parameters]].
*'''Offset''': <code>oTop</code> and <code>oLeft</code> define the upper left corner of the cropped image
*'''Crop''': <code>cWidth</code> and <code>cHeight</code> define the size of the cropped image
*'''Base Size''': Offset and Crop are calculated as if the original file had the width <code>bSize</code>


===Examples===
===Examples===


Create a cropped image of a single water drop:
Create a cropped image of only Sonic from the Sonic Vs Sonichu cover.


[[File:Dew on grass Luc Viatour.jpg|thumb|400px|left|Thumbnail of the '''original file''']]
[[File:SonicVsSonichu.jpg|thumb|250px|left|Thumbnail of the original file.]]


<div style="float: left; width: 120px; margin: 180px 0 0 30px;">
<div style="float: left; width: 150px; margin: 0 0 0 20px;">
{{CSS image crop
{{CSS image crop
|Image = Dew on grass Luc Viatour.jpg
|Image = SonicVsSonichu.jpg
|bSize = 400
|bSize = 400
|cWidth = 100
|cWidth = 150
|cHeight = 100
|cHeight = 170
|oTop = 180
|oTop = 230
|oLeft = 60
|oLeft = 180
|Description = One of Chris's earliest drawings of Sonic.
}}
}}
</div>
<div style="float: left; width: 300px; margin-top: 150px; font-size: 0.95em;">
*'''Offset''': <code>oTop</code> and <code>oLeft</code> define the upper left corner of the cropped image
*'''Crop''': <code>cWidth</code> and <code>cHeight</code> define the size of the cropped image
*'''Base Size''': Offset and Crop are calculated as if the original file had the width <code>bSize</code>
</div>
</div>


{{clear}}
{{clear}}
<pre>{{CSS image crop
|Image = Dew on grass Luc Viatour.jpg
|bSize = 400
|cWidth = 100
|cHeight = 100
|oTop = 180
|oLeft = 60
}}</pre>
In addition, the cropped image can have a caption-text and be positioned on the page:
* <code>Location=</code> to position (''center, right, left, none'')
* <code>Description=</code> to add a text to the caption
{{CSS image crop
|Image = Dew on grass Luc Viatour.jpg
|bSize = 400
|cWidth = 100
|cHeight = 100
|oTop = 180
|oLeft = 60
|Location = center
|Description = A drop of dew on grass (focus on the drop)
}}
<pre>{{CSS image crop
|Image = Dew on grass Luc Viatour.jpg
|bSize = 400
|cWidth = 100
|cHeight = 100
|oTop = 180
|oLeft = 60
|Location = center
|Description = A drop of dew on grass (focus on the drop)
}}</pre>
===See also===
* {{tl|Annotated image}}
** [[Template:Annotated image/doc/Samples#Cropping an image|with empty "annotations" parameter]]
** {{tl|IrinotecanPathway WP229}} (as used in article [[Multidrug resistance-associated protein 2]]), an example of how CSS Image Crop can combine with Annotated Image.
<includeonly>{{Sandbox other|
| <!-- CATEGORIES BELOW THIS LINE, PLEASE: -->
[[Category:Image formatting and function templates]]
}}</includeonly>

Latest revision as of 12:40, 30 September 2021

{{CSS image crop}} (Usage) creates a crop of an image inline for previewing the look and feel of a page, or for linking to full images when a slight crop is preferred in an article, but the full image is more encyclopedic in general. Where only a small section of the image is used after the crop, it's best to upload the crop as a new file, to avoid sending the extra image data to users.

Usage

{{CSS image crop
|Image         = The name of the image file. Don't include the 'File:' part.
|bSize         = The Base Image width in pixels (the image we are cropping on)
|cWidth        = Crop Image Width in pixels
|cHeight       = Crop image Height in pixels
|oTop          = Offset Top in pixels, optional and defaults to 0 when omitted
|oLeft         = Offset Left in pixels, optional and defaults to 0 when omitted
|Location      = 'right', 'left', 'center' or 'none'. Determines placement of the image on the page
                 Defaults to 'right' when description is provided (as is default for thumb images)
                 When description is blank, location on left (as is default for non-thumbs)
|Description   = Description (will render out using thumbnail class)
|Link          = Name of an article to be linked by clicking on the image (omit unless there is a
                 good reason to link to an article instead of the image).
|Alt           = The alt text for the image.
|Page          = The page of the file, if there are multiple pages (such as pdf files).
}}
  • Offset: oTop and oLeft define the upper left corner of the cropped image
  • Crop: cWidth and cHeight define the size of the cropped image
  • Base Size: Offset and Crop are calculated as if the original file had the width bSize

Examples

Create a cropped image of only Sonic from the Sonic Vs Sonichu cover.

Thumbnail of the original file.
One of Chris's earliest drawings of Sonic.
One of Chris's earliest drawings of Sonic.