TBieniek
TBieniek

Reputation: 4937

linked image in reStructuredText

How can I create a linked image with reStructuredText?

I've found

.. image:: /path/to/image.jpg

for images, and external hyperlinks like

'Python <http://www.python.org/>'_

for links, but I don't know how to combine them or if that is at all possible.

Upvotes: 63

Views: 15531

Answers (2)

G. Milde
G. Milde

Reputation: 897

Use the :target: option of the "image" or "figure" directive:

.. image:: /path/to/image.jpg
   :target: http://www.python.org/

Works also for an inline image:

.. |inline-image| image:: /path/to/image.jpg
   :target: http://www.python.org/
   :height: 1em

Paragraph with |inline-image|

For details, see the reStructuredText Directives and the reStructuredText Markup Specification.

Upvotes: 1

noelbk
noelbk

Reputation: 1463

Two ways to do it:

  1. in inline images:

    .. image:: pageflip-200.png
       :target: pageapplet/index.html
    
  2. With a reference, like:

    Click on my |ImageLink|_
    
    .. |ImageLink| image:: /images/link.png
    .. _ImageLink: http://link.url/
    

Upvotes: 107

Related Questions