Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2014-03-02 17:43:23

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

Re: [Textile] Figures and figcaptions

Phil,

I had to stop using this nice little variable, unfortunately. It was adding empty <p></p> tag sets around the image and the figcaption. I couldn’t figure out how to remove them. Even making all the tag elements come immediately after one another in the variable form didn’t work.

I only noticed it because there were abnormally wide gaps between the elements when using the variable method versus a figure/figcaption directly in the article. That’s when I looked at code output and discovered the intruding p sets.

Using the native (but bulkier) approach also gets rid of the caption/title issue from the Txp image data, which for my figures the caption data is kind of long. Alas.

So, as much as I really liked the simple images tag of your approach versus the bulk I need to use, it wasn’t working for me.

When 4.6 is out, we’ll at least have the image caption/title thing fixed. If you figure out how to rid those empty p sets too, that would be great. And if you don’t see them, then I’m equally puzzled by the problem.

Offline

#17 2014-03-02 17:47:43

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,785
GitHub

Re: [Textile] Figures and figcaptions

Destry wrote #279358:

It was adding empty <p></p> tag sets around the image and the figcaption. I couldn’t figure out how to remove them.

rah_replace

<txp:rah_replace from="<p>,</p>" to="">your tags</txp:rah_replace>

Offline

#18 2014-03-02 18:21:44

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

Re: [Textile] Figures and figcaptions

Good to know, thanks Pete. When the caption/title thing is fixed in 4.6, I might revert back. ;)

Offline

#19 2014-03-03 02:45:33

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

Re: [Textile] Figures and figcaptions

Independent of this discussion, I use since three months in a website the following code, without any problems, different as you describe. The code can’t produce empty tags.

<txp:if_article_image>
	<txp:images auto_detect="article" break="" form="image-thumbnail" />
</txp:if_article_image>

The form “image-thumbnail”:

<txp:variable name="has-caption" value='<txp:image_info type="caption" />' />

<txp:if_variable name="has-caption" value="">
	<img src="<txp:image_url thumbnail="1" />" alt="<txp:image_info type="alt" />" />
<txp:else />
	<figure>
		<img src="<txp:image_url thumbnail="1" />" alt="<txp:image_info type="alt" />" />
		<figcaption><txp:image_info type="caption" /></figcaption>
	</figure>
</txp:if_variable>

Offline

#20 2014-03-03 10:26:51

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,566
Website GitHub Mastodon

Re: [Textile] Figures and figcaptions

Destry wrote #279358:

I had to stop using this nice little variable, unfortunately. It was adding empty <p></p> tag sets around the image and the figcaption. I couldn’t figure out how to remove them. Even making all the tag elements come immediately after one another in the variable form didn’t work.

Ah, well spotted. You need to add a notextile. to that, like so:

notextile. <txp:images id="xx" form="images" />

I’ve edited my previous post to make note of that.

Offline

#21 2014-03-03 10:36:21

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,566
Website GitHub Mastodon

Re: [Textile] Figures and figcaptions

GugUser wrote #279367:

Independent of this discussion, I use since three months in a website the following code, without any problems, different as you describe. The code can’t produce empty tags.

Yes, but we are talking about how to easily add figures/figcaptions within article content as you write it, so in that sense your code would be identical to what I had (it’d wrap it in <p> tags). That’s just how Textile works.

Offline

#22 2014-03-03 13:01:48

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: [Textile] Figures and figcaptions

@Destry
Before install a new plugin, 2 thinks :

1- have you simply testing that ?

<txp:smd_wrap transform="textile" trim="0">

…If you add a space before your caption, textile don’t apply automatic <p>

2- smd_wrap has replace function. Not necessary to install a new plugin

Offline

#23 2014-03-03 19:38:46

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

Re: [Textile] Figures and figcaptions

philwareham wrote #279375:

Yes, but we are talking about how to easily add figures/figcaptions within article content as you write it.

Sorry, I should have known the difference.

Offline

#24 2014-03-07 13:21:50

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

Re: [Textile] Figures and figcaptions

philwareham wrote #279374:

Ah, well spotted. You need to add a notextile. to that, like so:

notextile. <txp:images id="xx" form="images" />...

I’ve edited my previous post to make note of that.

Aha. Thanks.

Offline

#25 2016-03-18 08:07:52

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

Re: [Textile] Figures and figcaptions

Phil,

(I’m being lazy web.)

I take it this is still the core modus operandi in 4.6?

(Catching up again.)

Offline

#26 2016-03-18 09:13:46

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,566
Website GitHub Mastodon

Re: [Textile] Figures and figcaptions

@destry

Yep.

Offline

#27 2016-08-17 23:46:24

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

Re: [Textile] Figures and figcaptions

Loving that this now works. Articles are so much cleaner without the full fig caption complex in the body, and that captions behave as they should (not as title attributes).

One question now… How can I get textile (and/or markdown) that is used in the caption field to render on output? We did this in the TXP Mag, but I can’t remember what the process was.

Wouldn’t that make the DITA people cry… Formatting within structured raw text fields. ;)

Offline

#28 2016-08-18 08:43:35

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,218
Website GitHub

Re: [Textile] Figures and figcaptions

Destry wrote #300694:

One question now… How can I get textile (and/or markdown) that is used in the caption field to render on output? We did this in the TXP Mag, but I can’t remember what the process was.

How about with:

<txp:smd_wrap transform="textile"><txp:image_info type="caption" /></txp:smd_wrap>

But you will get an extra <p> wrap tag. If you want to strip that out, you need to chain on additional replace transform:

<txp:smd_wrap transform="textile,replace|regex|'<\/?p>'|"><txp:image_info type="caption" /></txp:smd_wrap>

I think that should work.

The other nice thing about farming off the image stuff to a separate form is that you can adapt it later, for example to add srcset tags without having to revisit the body fields again.

If you use smd_macro or rah_beacon, you can extend that principle and make your own txp:tags for images, figures or image groups. For example, you can make a form or smd_macro called figure and you need only insert <txp:figure id="123" /> into your body field. The whole code block including txp:images goes into that form*. You can go further to include a custom caption="my caption" to override the image’s own caption or caption="" to suppress the caption. The form gets more complex but your author’s body field remains cruft-free.

What I would really like now is a customisable tag-builder for making it easier for authors to pick images and insert that tag.

*Note: if using rah_beacon, you need to avoid using form names that collide with txp’s own tags (e.g. your form can’t be called images or image. I have a fork of rah_beacon that avoids that problem.


TXP Builders – finely-crafted code, design and txp

Offline

#29 2016-08-18 10:25:00

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

Re: [Textile] Figures and figcaptions

Sweet into, Jakob. Thanks!

I went with the second wrap, to remove the p. But since the tag I’m using in the body is, for example:

notextile. <txp:images id="78" form="images-body" />

The textile that’s added by smd_wrap is turned off again at the point location by notextile.. I’m assuming that’s what’s happening, because the textile doesn’t render.

Hmm… Those damn Textile p tags have always been such a pisser. I’ll just go with no textile in captions. Less confusing for editors anyway than having to explain the ability of using Textile in caption fields. Links in caption, for example, are nice to have/offer when dealing with image owners (link backs), but not critical.

jakob wrote #300699:

What I would really like now is a customisable tag-builder for making it easier for authors to pick images and insert that tag.

Yes! And the ability to position figures of varying widths right or left too, instead of being stuck with full-width figures. So either by adding prefab classes, or via a width-percentage picker/text field, and a float-direction picker.

And, yeah, smd_macro is something I really need to look closer at. Never used it yet. I wonder if that would solve the textile problem I’m running into?

Last edited by Destry (2016-08-18 10:29:38)

Offline

#30 2016-08-18 10:37:08

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

Re: [Textile] Figures and figcaptions

jakob wrote #300699:

For example, you can make a form or smd_macro called figure and you need only insert <txp:figure id="123" /> into your body field. The whole code block including txp:images goes into that form*.

That scenario and form would make a nice Textpattern Tip (you listening, Stubbs?). I remember someone once suggesting a similar doc source specifically for “smd_macro” solutions too, also a good idea. Plug and play pattern solutions! As fun as it might be to wade through plugin documentation on a busy schedule, being able to just copy/paste the right macro would be great too.

Offline

Board footer

Powered by FluxBB