images.adoc 2.91 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
= Images

There are two AsciiDoc image macro types, block and inline.

== Block image macro

A [.term]*block image* is displayed as a discrete element, i.e., on its own line, in a document.
A block image is designated by `image` macro name and followed by two colons (`::`)
It's preceded by a blank line, entered on a line by itself, and then followed by blank line.

.Block image macro
[source#ex-block]
----
Content in document.

16
include::example$image.adoc[tag=base] <.> <.>
17
18
19
20
21
22
23
24
25

Content in document
----
<.> To insert a block image, type the `image` macro name directly followed by two colons (`::`).
<.> After the colons, enter the image file target.
Type a set of square brackets (`+[]+`) directly after the target to complete the macro.

The result of <<ex-block>> is displayed below.

26
include::example$image.adoc[tag=base]
27
28
29
30
31
32
33

You can specify a comma-separated list of optional attributes inside the square brackets or leave them empty.
If you want to specify alt text, enter it inside the square brackets.

.Block image macro with alt text
[source#ex-alt]
----
34
include::example$image.adoc[tag=alt]
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
----

You can also give the image an id, title, set its dimensions and make it a link.

.Block image macro with attribute list
[source#ex-attributes]
----
include::example$image.adoc[tag=attr-co]
----
<.> Assigns an ID to the block.
<.> Defines the title of the block image, which gets displayed underneath the image when rendered.
<.> `link` makes the image a link (this can also be defined inside the attribute list of the block macro)
<.> The first positional attribute, _Sunset_, is the image's alt text.
<.> The second and third positional attributes define the width and height, respectively.

The result of <<ex-attributes>> is displayed below.

include::example$image.adoc[tag=attr]

=== Figure caption label

When a title is defined on a block image, the image title will be prefixed by a caption label (Figure) and numbered automatically.
To turn off figure caption labels and numbers, unset the `figure-caption` attribute in the document header.

[source]
----
= Document Title
:figure-caption!:
----

== Inline image macro

An [.term]*inline image* is displayed in the flow of another element, such as a paragraph or sidebar block.
The inline image macro is almost identical to the block image macro, except its macro name is followed by a single colon (`:`).

.Inline image macro
[source#ex-inline]
----
Click image:play.png[] to get the party started. <.>

Click image:pause.png[title="Pause"] when you need a break. <.>
----
<.> In the flow of an element, enter the macro name and a single colon (`+image:+`), followed by the image target.
Complete the macro with a set of square brackets (`+[]+`).
<.> You can specify a comma-separated list of attributes inside the square brackets or leave them empty.

The result of <<ex-inline>> is displayed below.

83
include::example$image.adoc[tag=inline]
84
85

For inline images, the optional title is displayed as a tooltip.