Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2014-02-17 07:58:49

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

Re: [Textile] Figures and figcaptions

Phil,

Just a suggestion, because I wasted a bit of time trying to do this (mostly because I forgot about escape=""), I would recommend replacing the last comment and code for figcaption to this…

<!-- you do not need to specify the attribute type="caption" in the img_info tag
      as that is the default setting for <txp:image_info /> tag, so we remove it here -->
<figcaption itemprop="caption"><txp:image_info /></figcaption>

<!-- optionally, you can make Textile work in the caption by wrapping the 
      figcaption with a plugin tag like smd_wrap that uses the transform="textile" attribute, 
      and by adding the escape="" attribute in the image_info tag, which specifically 
      makes Textile links work; do this by installing smd_wrap, uncommenting the 
      following, and removing the figcaption code above   -->

<!-- <txp:smd_wrap transform="textile">
<figcaption itemprop="caption"><txp:image_info escape="" /></figcaption>
</txp:smd_wrap> -->

So the first part is the same except the type="caption" attribute is actually removed since you make it clear in the comment that it’s unnecessary.

The second part is a helpful option, commented out because it requires a plugin. This is useful because it helps people like me who want to go all the way and use Textile in captions, which, I think would be most people once they realized it was possible.

As another suggestion, you could change all the comments to use txp:hide instead of <!-- ... -->, which prevents anyone from seeing them if they look at a page’s source code. For example, I’ve done all the above and my last bit reads like this…

<txp:hide>
The attribute type="caption" is removed here since it's the default setting 
for <txp:image_info /> tag. Textile is made possible by wrapping the the figcaption 
with smd_wrap (plugin), declaring the transform="textile", and adding 
escape="" in the image_info tag.
</txp:hide>

<txp:smd_wrap transform="textile">
  <figcaption itemprop="caption"><txp:image_info escape="" /></figcaption>
</txp:smd_wrap>

With that all is how I want it.

Offline

#14 2014-02-17 08:03:37

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

Re: [Textile] Figures and figcaptions

@destry

I can’t do that as the default theme needs to be completely free of plugin references. I’ll re-look at the original code though and see if there’s a better solution.

Offline

#15 2014-02-17 08:07:44

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

Re: [Textile] Figures and figcaptions

Oh, licensing thing, maybe? That would make sense.

What if instead of indicating a plugin, you gave a link in the comment to a “tutorial” in the docs or TXP tips for making Textile work too?

Offline

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

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
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,134
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,909
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,473

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,564
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,564
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,473

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,909
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

Board footer

Powered by FluxBB