Go to main content

Thumbnail

Contents

Syntax

<txp:thumbnail />

The thumbnail tag is a single tag that Textpattern will replace with the <img src="…"> HTML tag matching the thumbnail image of the numeric id assigned by Textpattern when the parent image was uploaded via the Textpattern Images panel.

By default, the tag is context-sensitive: if an id or name attribute is not specified, it can be used inside an images tag or form to output an <img src="…"> HTML tag matching the thumbnail of the current image.

Attributes

Tag will accept the following attributes (case-sensitive) as well as the global attributes :

escape="html" v4.0.4+
Escape HTML entities such as <, > and & for the image’s alt and title attributes.
Values: See the tag escaping documentation for all possible values.
Default: html.
height="integer" v4.3.0+
Specify an image height which overrides the value stored in the database. Use height="0" to turn off the output of a width attribute in the <img> tag (thus the browser will scale the height if a width is used).
html_id="id" v4.0.4+
The HTML id attribute assigned to the image (or to the wraptag, if set).
Default: unset.
id="integer"
Specifies the id assigned at upload of the image to display. Can be found on the Textpattern Images panel. If both name and id are specified, name is used while id is ignored. If neither is specified, the tag must be used within an images tag or form.
link="boolean" v4.0.6+
If set, the thumbnail will be rendered as a (non-Javascript) URL link to the full-size image.
Values: 0 (no) or 1 (yes).
Default: 0.
link_rel="relation" v4.0.6+
Value for the HTML rel attribute.
Default: unset.
loading="text" v4.8.3+
HTML loading attribute to be applied to image. Specifies how a browser should handle loading of the image.
Values: lazy (defers loading the image until it reaches a calculated distance from the viewport, as defined by the browser), eager (loads the image immediately, regardless of whether or not the image is currently within the visible viewport).
Default: unset.
name="image name"
Specifies which image thumbnail to display by its image name as shown on the Textpattern Images panel.
poplink="boolean" (Deprecated from version 4.7.0)
If set, the image will be rendered in a popup window.
Values: 0 (no) or 1 (yes).
Default: 0.
style="style rule"
Inline CSS style rule. It’s recommended that you assign CSS rules via the class attribute instead.
Default: unset.
title="boolean|title text" v4.8.0+
Adds the given text as an HTML ‘title’ attribute to the image. If used as a valueless attribute, will use the caption as text.
width="integer" v4.3.0+
Specify an image width which overrides the value stored in the database. Use width="0" to turn off the output of a width attribute in the <img> tag (thus the browser will scale the width if a height is used).

Common global attributes

These attributes are shared by all tags - and plugins, provided they do not override the functionality.

break="value"
Where value is an HTML element, specified without brackets (e.g. break="li") or some string to separate list items.
Default: br (see break cross-reference).
breakby="integer(s)"
Used to group list items when separating by break. Possible values are lists of integers, like 2 (groups of 2 items) or 1,2 (alternate groups of 1 and 2 items). Otherwise, the value is evaluated on each loop and `break` happens as soon as it changes. Note that `string` must be enclosed in *double* quotes.
Default: 1 (unset) (see breakby cross-reference).
breakform="form name"
A form to be used as `break`, generally jointly with `breakby` attribute. The special `<+>` pattern in this form will be replaced with the list "chunk" accumulated when break happens.
Default: unset (see breakform cross-reference).
class="class name"
HTML class to apply to the wrapper.
Values: Any valid string.
Default: unset.
default="value"
The value to display if the tag's output is blank.
Values: Any.
Default: unset.
escape="list, of, transforms"
The transforms to apply to the output. See tag escaping for details.
Values: html, js, json, url, float, integer, number, ordinal, spell, lower, upper, title, [r|l]trim, quote, tags, textile, _any tag_
Default: html.
evaluate="number list"
Alter the processing order of top-level tags inside a form/container. Tags are normally executed from top to bottom. If you wish to change this order, imagine Textpattern tags are numbered incrementally from 1 inside a container. To process tags 3 and 5 first, then 1, 2, and 4, specify evaluate="3, 5" in your container tag.
Values: Any comma-separated numbers corresponding with the numerical position of primary (top-level) tags inside the container.
Default: unset.
html_id="value"
HTML id to apply to the wrapper.
Values: Any valid string.
Default: unset.
label="value"
The label to display before the output.
Values: Any valid string.
Default: unset.
labeltag="tag"
The tag (without angle brackets) to wrap the label.
Values: Any valid HTML tag, e.g. h3 or div.
Default: unset.
not="boolean"
Switch parts.
Values: 0 (no) or 1 (yes).
Default: unset (0).
replace="string"
Replace the content stripped via the trim attribute.
Values: Any valid string.
Default: unset.
trim="string or regex"
Remove the matching patterns from the output.
Values: Any. Use /value/ to trigger regular expression matching, otherwise the value will be treated verbatim as a set of characters to trim.
Default: unset.
wrapform="form name"
The form to be used as wraptag. Handy if the wraptag pattern is too long, or is reused.
Values: Any defined form name.
Default: unset.
wraptag="tag or pattern"
The tag (without angle brackets) to wrap the output.
Values: HTML tag or a string containing <+> pattern that will be replaced by the output.
Default: unset.

Examples

Example 1: Display the given thumbnail

<txp:thumbnail id="23" />

Displays the image thumbnail for the image uploaded as ID #23.

Example 2: Use within images tag

<txp:images>
    <txp:thumbnail />
</txp:images>

Displays thumbnails for all images found by the images tag.

Genealogy

Version 4.8.3

loading attribute added.

Version 4.8.0

title attribute added.

Version 4.7.0

poplink attribute deprecated.

Version 4.3.0

height and width attributes added.
Added context sensitivity within images tag.

Version 4.2.0

align attribute deprecated.

Version 4.0.7

Default value for escape attribute changed from ‘unset’ to html.

Version 4.0.6

link and link_rel attributes added.

Version 4.0.4

escape, html_id and wraptag attributes added.

If you notice any kind of problem with this page's construction or content (outdated information, typos, broken links, or whatever), open an issue to have it sorted. Or have a go at it yourself. :)