Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-05-21 19:48:17

ookpik
Member
Registered: 2005-05-05
Posts: 18

Putting a link in an image caption?

Hi folks.

Anyone got a trick for putting a valid link in the image caption field? I use linked photo credits all the time (for example), and it would be great to save the credit with the image. (Currently I paste the image into an article and type the caption there.) This is especially necessary for a site I’m building now where non-tech people will be re-using images.

When I use Textile or HTML in the caption, it gets escaped and printed out as is. Like this:

"Photo by Peter Gardner / pg photos":http://pgphotos.org/?p=93

or

<a href="http://pgphotos.org/?p=93">Photo by Peter Gardner / pg photos</a>

I don’t think upm_textile can do the trick because of the escaping.

My remaining ideas are to hack Txp to turn off escaping in the caption field (sketchy!), or use php to de-escape the caption, then wrap it in upm_textile (convoluted!).

Thanks for any other angles on this. I hope I’m missing something simple!

Offline

#2 2009-05-21 20:13:38

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Putting a link in an image caption?

My soo_image plugin has a caption tag with an escape attribute. I’m guessing the other major image plugins also have this.


Code is topiary

Offline

#3 2009-05-21 20:16:57

ookpik
Member
Registered: 2005-05-05
Posts: 18

Re: Putting a link in an image caption?

@#$*

Annnnd…. missing something simple.

I should have mentioned (!) that I was using the mighty upm_image to output the image caption, and it has an “escape” attribute.

Thanks for sharing my awkward moment.

Offline

#4 2012-10-13 13:46:49

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Putting a link in an image caption?

How can I put a link in the occasional image caption preferably using only the new image tags?

Last edited by joebaich (2012-10-13 13:47:06)

Offline

#5 2012-10-13 13:57:06

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Putting a link in an image caption?

<txp:image_info /> shows a HTML-link in a caption text, and the link works.

Last edited by GugUser (2012-10-13 14:00:17)

Offline

#6 2012-10-13 16:33:00

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Putting a link in an image caption?

Something like this as a caption doesn’t produce a link for me.

This is a caption containing <a href="http://mysite.com>a link to my site</a>

It just appears verbatim in the caption.

Offline

#7 2012-10-13 16:45:42

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Putting a link in an image caption?

I tested it in a site with the following context and it works in the part title="<txp:image_info />" in the form:

<txp:images sort='field(id, <txp:custom_field name="article_image" />)' wraptag="ul" class="galerie" break="li" form="fotos-galerie-miniaturen" />

Form:

<a href="<txp:image_url />" class="gross" title="<txp:image_info />"><img src="<txp:image_url thumbnail="1" />" width="<txp:image_info type="thumb_w" />" height="<txp:image_info type="thumb_h" />" alt="<txp:image_info type="alt" />" /></a>

The caption text is stored with the image in the image page.

Offline

#8 2012-10-13 16:54:02

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Putting a link in an image caption?

A temporary example:

Zoom the last image at the bottom.

Edit: The temporary example was removed.

Last edited by GugUser (2012-10-18 23:57:33)

Offline

#9 2012-10-13 17:03:02

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,396
Website GitHub Mastodon Twitter

Re: Putting a link in an image caption?

joebaich wrote:

Something like this as a caption doesn’t produce a link for me.

This is a caption containing <a href="http://mysite.com>a link to my site</a>

It just appears verbatim in the caption.

Hi Joe can you please post the code you are using?

> edited to add

<txp:image_info type="caption" escape="" /> might work for you

Last edited by colak (2012-10-13 17:15:10)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#10 2012-10-13 17:19:03

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Putting a link in an image caption?

GugUser thank you for the rapid response and live example. I will see if I can adapt that to my current requirement which is an ad hoc link in an article image caption. I need to provide an attribution link for the image I want to use.

colak My code

<txp:if_article_image><txp:images><txp:article_image class="fine-border"/><txp:image_info type="caption" wraptag="span" class="img_cap" /></txp:images></txp:if_article_image>

As indicated above, my link was straight HTML witten into the caption associated with the image.

Offline

#11 2012-10-13 17:27:45

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Putting a link in an image caption?

colak wrote:

<txp:image_info type="caption" escape="" /> might work for you

It did! Thanks Yiannis.

Offline

#12 2012-10-13 17:44:33

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: Putting a link in an image caption?

In my example the Link <a href="http://san-andres-ev.de/">Home</a> is written into the caption associated with the image, like you propose.

And: You don’t need the <txp:article_image /> tag and type="caption" is default.

Offline

#13 2012-10-14 04:20:40

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,396
Website GitHub Mastodon Twitter

Re: Putting a link in an image caption?

Hi Joe

You could also try

<txp:if_article_image>
<txp:images>
<img src="<txp:custom_field name="article_image" />"<txp:image_info type="ext">" width="<txp:image_info type="w" />" height="txp:image_info type="h" />" alt="<txp:image_info type="alt" />
<txp:image_info type="caption" wraptag="span" class="img_cap" escape=""/>
</txp:images>
</txp:if_article_image>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#14 2012-10-16 11:15:08

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Putting a link in an image caption?

If you’ve been reading TXP, you may have noticed we use links in figure captions. The links are entered directly inline in the image caption using raw HTML. Stef created a custom image insert functionality (handled via the Write panel) so you put the curser in the article where you want the image to appear, select the image and styling type definition, click presto, and a tage like <txp:figcap name="file-name.png" /> is entered in place. When rendered, the image and associated caption with link are right there. It’s lovely. You’re clients will praise you.

I think he’s working on a plugin for it to release eventually. He talked about it. See section, Simplifying image insertion.

Offline

Board footer

Powered by FluxBB