साँचा:Img float

विकिस्रोत से
नेविगेशन पर जाएँ खोज पर जाएँ
Template documentation[view] [edit] [history] [purge]

Usage[सम्पादन]

Creates floating image and caption.

{{Img float
 | style =
 | above =
 | file     = 
 | width    = 
 | align    = 
 | polygon  = 
 | cap      = 
 | capalign = 
 | alt      = 
}}

Parameters[सम्पादन]

  • style: add css style attributes. If you change font size by percent you should also change line-height. For example if you want font-size to be 80%: | style = font-size: 80%; line-height: 80%;
  • above: add text above picture
  • file: The file name (without the "File:" prefix) (mandatory parameter)
  • width: The width of the image (optional, default 150px)
  • align: The alignment of the image on the page ("left", "right" or "center"; default "right")
  • polygon: Polygon shape outline to allow text to wrap closer to the image if the image is not a rectangle (optional, co-ordinates as comma separated pairs)
  • cap: The image caption (optional). Do not use any <div> or div-based templates such as {{smaller block}} if the template is located in the middle of a paragraph as Mediwiki will add a paragraph break.
  • capalign: The image caption text alignment ("left", "right" or "center"; default "center")
  • alt: Image alt-text, ie. for mouse-over text box or for use with a screenreader for the visually impaired (required for accessibility)
 

Because this is a span-based template (to allow it to "float" within paragraphs without breaking the paragraph), it is disallowed to use block formatting (for example {{center}} or {{smaller block}}) in the captions.

Example[सम्पादन]

Image on right[सम्पादन]

{{Img float
 | file     = The Kinematics of Machinery Fig 2.jpg
 | width    = 250px
 | align    = right
 | cap      = Fig. 2.
}}


Fig. 2.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Image on left[सम्पादन]

{{Img float
 | file     = The Kinematics of Machinery Fig 2.jpg
 | width    = 250px
 | align    = left
 | cap      = Fig. 2.
}}


Fig. 2.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Left aligned image caption[सम्पादन]

{{Img float
 | file     = The Kinematics of Machinery Fig 2.jpg
 | width    = 250px
 | align    = right
 | cap      = Fig. 2.
 | capalign = left
}}


Fig. 2. On the left.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Image on right with above text[सम्पादन]

{{Img float
 | style = 
 | above = Fig. 2
 | file     = The Kinematics of Machinery Fig 1.png
 | width    = 250px
 | align    = right
 | cap      = This is image of kinematics of machinery fig 1.
}}

Fig. 2

This is image of kinematics of machinery fig 1.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Image in centre[सम्पादन]

{{Img float
 | file     = The Kinematics of Machinery Fig 2.jpg
 | width    = 250px
 | align    = center
 | cap      = Fig. 2.
}}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.
Fig. 2.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Image in centre without template[सम्पादन]

Alternatively, don't use a template for this, just insert the image followed by the caption like this:

{{lorem ipsum}}
[[File:The Kinematics of Machinery Fig 1.png|center|250px]]
{{c|Fig.2}}

{{lorem ipsum}}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

The Kinematics of Machinery Fig 1.png

Fig.2

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Polygon shape outlines[सम्पादन]

If the image is not a rectangle, and you want text to wrap closer to the image, use the polygon parameter. This parameter uses CSS polygon syntax: comma separated pairs of co-ordinates, either given as a percentage (e.g. 20%, 50%).

Note: Pixel values (e.g. 10px, 25px) may appear to work, but they will result in the text being wrapped incorrectly on the mobile interface if the image is scaled to fit the screen (which will happen on most phone screens if the image is wider than about 350px). Therefore, prefer the relative percentage sizes where possible.

Note: this sets the CSS shape-outside style, which overrides the margin-box for text-wrapping. This means if you set margins in the style parameter, they will be ignored if you also set polygon.

{{img float
|file=Select Popular Tales from the German of Musaeus (drop cap, page 1).jpg
|align=left
|width=300px
|polygon=0 0, 100% 0, 100% 34%, 60% 34%, 60% 58%, 36% 58%, 36% 100%, 0 100%
}}
{{lorem ipsum}}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.

Caution: divs break paragraphs and cause linter errors[सम्पादन]

This template is a span-based template, which means it can "float" within a paragraph without breaking the surrounding text into two paragraphs.

However this means that you cannot use any div-based formatting within the cap field.

{{lorem ipsum}}
{{Img float
 | file     = The Kinematics of Machinery Fig 2.jpg
 | width    = 250px
 | cap      = {{smaller block|This is a div-based template and will break the paragraph where the template is inserted.}}
}}
'''Break!''' {{lorem ipsum}}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.


This is a div-based template and will break the paragraph where the template is inserted.

Break! Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo.


See also[सम्पादन]

  • {{Flow under}}: allows text to flow under parts of an image, similarly to using |polygon=
  • {{Overfloat image}}: performs reverse operation to this template, i.e. text is floated above an image element