Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Adding a caption to an image output by the Article Image field
I would like to add a string under the article image that is output via the Article Image field in admin area? is this possible or will TXP 5 handle that?
in the Body i can add this code ( it can be as simplified to bare bones in terms of image and text) :
<figure style="float:left; padding: 5px 5px 10px 20px;"" > <img class="imgr borderedbox inspace-5" src="./images/381.png" style="width:520px" name="foto" alt="image" ><figcaption_books class="inspace-15 center"> A wee caption under photo </figcaption></figure>
Doable via the admin side?
…. texted postive
Offline
Re: Adding a caption to an image output by the Article Image field
Possible now!
On the admin side, images > edit image there is a caption field, under the alt field. Fill in your prose
in your form or article:
<figcaption>
<txp:image_info type="caption" />
</figcaption>
You’re done.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: Adding a caption to an image output by the Article Image field
well I’ll be! .. good to hear.
but I tried this in my form without any results:
<txp:if_article_image>
<txp:article_image wraptag="p" class="article-image" width="720"/> <figcaption>
<txp:image_info type="caption" /> </figcaption>
</txp:if_article_image>
…. texted postive
Offline
Re: Adding a caption to an image output by the Article Image field
Strange… Doesn’t <txp:article_image /> get the image information?
Try this:
<txp:if_article_image>
<txp:images>
<figure>
<txp:image />
<figcaption><txp:image_info type="caption" /></figcaption>
<figure>
</txp:images>
</txp:if_article_image>
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
Re: Adding a caption to an image output by the Article Image field
phiw13 wrote #341176:
Strange… Doesn’t
<txp:article_image />get the image information?Try this:
<txp:if_article_image>...
magical! thanks..
I don’t know why I had never thought that this was possible to do! .
EDIT: I cannot get the caption to not continue on a new line and not to centre but align left under the image! this code
<figure> <txp:image /><figcaption class="inspace-15 left"><txp:image_info type="caption"/></figcaption> <figure>
starts the caption on the left but continues on a new line that is centred and a space between lines added. odd
Last edited by bici (Today 03:37:52)
…. texted postive
Offline
Re: Adding a caption to an image output by the Article Image field
bici wrote #341177:
I don’t know why I had never thought that this was possible to do!
Yes, in the docs it says txp:image_info “should usually be used in an ‘image’ type form, although it may be used on its own providing you specify an id or name.”
EDIT: I cannot get the caption to not continue on a new line and not to centre but align left under the image! this code … starts the caption on the left but continues on a new line that is centred and a space between lines added.
That will have to do with your css styling. The default browser styling for figure and for figcaption is display: block; which places them on a line of their own. figure additionally has a bit of top and left margin, if not overridden. If no other styles are influencing that, they should both be left-aligned by default, so the centering is likely coming from elsewhere in your styles.
See this test case (look in the css tab to see the alternative inline styling).
If you want to force the caption to be on one line, investigate text-wrap: nowrap; in your css, but note that it can play havoc with your layout if your caption is long.
EDIT: If you do …
<txp:image_info wraptag="figcaption" class="myclass" />
… you can avoid an empty figcaption being output if you don’t specify a caption.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Adding a caption to an image output by the Article Image field
jakob wrote #341178:
Yes, in the docs it says txp:image_info “should usually be used in an ‘image’ type form, although it may be used on its own providing you specify an id or name.”
That will have to do with your css styling. The default browser styling for
figureand forfigcaptionisdisplay: block;which places them on a line of their own.figureadditionally has a bit of top and left margin, if not overridden. If no other styles are influencing that, they should both be left-aligned by default, so the centering is likely coming from elsewhere in your styles.See this test case (look in the css tab to see the alternative inline styling).
If you want to force the caption to be on one line, investigate text-wrap: nowrap; in your css, but note that it can play havoc with your layout if your caption is long.
EDIT: If you do …
<txp:image_info wraptag="figcaption" class="myclass" />...… you can avoid an empty figcaption being output if you don’t specify a caption.
thanks… I do have some css voodoo happening that I need to adjust. good tip about empty captions.
…. texted postive
Offline
Re: Adding a caption to an image output by the Article Image field
The browser dev tools can be indispensable for finding out what’s influencing your styles. In case it’s of use to anyone, Kevin Powell and Amit Sheen have put out a free CSS DevTools for Beginners course that goes through the main panels step by step.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Adding a caption to an image output by the Article Image field
phiw13 wrote #341176:
Strange… Doesn’t
<txp:article_image />get the image information?
It does, but it is a single tag outputting image lists following a hard-coded format. There is no way (other than attributes) to get ‘inside’ the tag and alter this format.
Offline