Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-07-14 20:01:50

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 276

how to assign custom title for article image?

i want to assign title for article image, i did the following code but not works:
<txp:article_image title=”<txp:title />” />

Offline

#2 2014-07-14 20:52:50

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: how to assign custom title for article image?

title is not an attribute for article_image: www.textpattern.net/wiki/index.php?title=article_image.

You have either to enter the title in the caption field, or (little trick inside):

<img src="<txp:image_url id='<txp:custom_field name="article_image" />' />" title='<txp:title />'/>

Offline

#3 2014-07-14 22:53:34

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 276

Re: how to assign custom title for article image?

you mean, i have to type image ID to custom field manually for each article ?
that might be complex for my client !

Offline

#4 2014-07-14 23:13:47

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: how to assign custom title for article image?

Offline

#5 2014-07-14 23:24:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: how to assign custom title for article image?

I’m a little confused, perhaps I’ve misunderstood your intentions. What title do you want to assign to each article image? From your opening post, it seems you want to use the title of the article as the title for every article image. But from the subsequent post, it seems you don’t want to put image IDs into your article because it’s too complicated.

Firstly, there are plenty of plugins (such as abl_droploader or the one mrdale proposed) which will allow you to assign an image to an article using drag and drop, or ‘select from a list’.

Secondly, as CeBe says, if you want to assign a title to each image, the proper place to do it is in one of the Image fields. So you have a choice of Filename, Alt or Caption. Just pick one and use it consistently. Caption is probably the most “correct” field to use in this situation, but it’s entirely up to you.

Once you have captions in all your images, you can use txp: tags to display the information you want. <txp:article_image> is a little restrictive in its output, so if you want complete control over your layout, I suggest using txp:images as a container tag. It will automatically detect any article images you have assigned, so all you need in your default Form is something like:

<txp:if_article_image>
   <txp:images wraptag="ul" break="li">
      <txp:image />
      <txp:image_info type="caption" wraptag="span" class="img-caption" />
   </txp:images>
</txp:if_article_image>

That will display each assigned article image and its caption. If you have multiple (comma-separated) image IDs in your article image field, it will display them all.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2014-07-15 08:40:22

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: how to assign custom title for article image?

raminrahimi wrote #282122:

i want to assign title for article image, i did the following code but not works: <txp:article_image title='<txp:title />' />

In case it helps:

<txp:etc_query data='<txp:article_image />' replace='//img@@title=whatever you need' />

And this one will simply remove link titles:

<txp:etc_query data='<txp:smd_calendar />' replace="//a/@title" />

Offline

#7 2014-07-15 15:34:41

raminrahimi
Member
From: India
Registered: 2013-03-19
Posts: 276

Re: how to assign custom title for article image?

thanks ETC, you are the best :-)
but the titles not coming complete !

Offline

#8 2014-07-16 11:39:10

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: how to assign custom title for article image?

raminrahimi wrote #282162:

thanks ETC, you are the best :-)

Not as propagandist, nobody seems to think of etc_query spontaneously, even for tasks it is designed for.

but the titles not coming complete !

They will be cut at ; (the default separator value). If this is the issue, just call etc_query with separator="something_else". Otherwise, please provide more details.

Offline

Board footer

Powered by FluxBB