Link on an image

Post here questions and problems related to editing and publishing DITA content.
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Link on an image

Post by Le Basque »

Hello,

How do I put a link on an image in DITA (link to a topic)
thank you
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Link on an image

Post by sorin_ristache »

Hello,

Do you want the action of clicking on an image in DITA XHTML output to open a new topic in the browser? You should try the DITA <image> element inside an element that creates a link to other topic, for example <xref>:

Code: Select all

<xref keyref="flowers.perennial" format="dita">perennial <image href="../images/Chrysanthemums.jpg"/></xref>

Regards,
Sorin
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: Link on an image

Post by Le Basque »

Hi,

I want to use PDF, when i indicate <xref keyref="task2.dita#task2.dita">XX<image href="schema_row2.png"></image></xref>
the image is not active and the link does not work

thank you
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Link on an image

Post by sorin_ristache »

Hello,

First make sure that clicking on the link works (jumps to the task2 topic in the PDF viewer application) when you have only a text in the link:

Code: Select all

<xref keyref="task2.dita#task2.dita">XX</xref>
This should work, it is just a normal link to other part of the PDF output. After this works correctly you can also add the image in the <xref> element. Please make sure that the file path to the image file is correct, in your example schema_row2.png.


Regards,
Sorin
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: Link on an image

Post by Le Basque »

If I simply shows the relationship <xref href="task2.dita#task2.dita"/> it is OK
If i indicate <image href="schema_row2.png"></image> the image is displayed
If i indicate <xref keyref="task2.dita#task2.dita"><image href="schema_row2.png"></image></xref> I do not have the link or the picture?

Thank you
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Link on an image

Post by sorin_ristache »

Maybe the path to the image was correct in the topic where you inserted only the <image> element, but is not correct in the topic where you inserted the element <xref keyref="task2.dita#task2.dita"><image href="schema_row2.png"></image></xref> ? If the <xref> element creates a link in the PDF output when it contains only text (no image) and the image is displayed correctly when inserted in the same DITA topic using the same path as in the <xref> element (<image href="schema_row2.png">) then the image should be displayed and act as a clickable link when you insert the element:

Code: Select all

<xref keyref="task2.dita#task2.dita"><image href="schema_row2.png"></image></xref>
This is what I get in a sample DITA where I tried this.

Does the output view called DITA OT [PDF] contain errors when you run the DITA PDF transformation? By default this view is not displayed, so you will have to enable it with the setting called Show console output - Always available on the Output tab of the DITA transformation dialog box.


Regards,
Sorin
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: Link on an image

Post by Le Basque »

Indeed there is a mistake, but I do not understand

thank you

xxxxxxxxxxxxxx\IMAGES_CLIQUABLE\Image_map_examples\schema_table.ditamap
Nom du moteur: DITA-OT
Gravité: info
Description: [DOTJ047I] Unable to find key definition for keyref="task2.dita#task2.dita", href may be used as fallback if it exists.
URL: http://dita-ot.sourceforge.net/readme/D ... __DOTJ047I
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Link on an image

Post by sorin_ristache »

Please look at the description of the error code pointed to by the error message in the Oxygen errors view. It seems your DITA key is not defined correctly or the target of the key cannot be found in the content of your current map. You can find details about working with DITA keys for example here.


Regards,
Sorin
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: Link on an image

Post by Le Basque »

That the link works without error must be indicated :

Code: Select all

<xref href="task2.dita#task2.dita"> <image href="schema_row2.png"/></xref>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Link on an image

Post by sorin_ristache »

If you are not using a DITA key then that is correct, you have to use the href attribute for creating the link to other topic, not the keyref one. So it does not matter if an image is inserted or not in the clickable area of the link, the important thing is to use in the xref element the correct attribute and file path to the target topic.


Regards,
Sorin
Le Basque
Posts: 147
Joined: Sat Oct 19, 2013 8:21 am

Re: Link on an image

Post by Le Basque »

Thank you
Post Reply