Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-09-13 15:46:31

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

<txp:image id="" link="" />

I am not a fan of JavaScript galleries, often I prefer plain HTML <a href="full_size_image.jpg"><img></a> instead.

Why there is no such (optional) attribute link="" or url="" of <txp:image /> tag? With a corresponding input field on [Images] panel of Textpattern?

I could use <txp:thumbnail linked="1" /> sometimes, although:

  • I can not link it to an external source;
  • sometimes I would like to point the image to SVG, PDF, another file source, or an entire HTML page (internal or external);
  • sometimes (quite often) I need both full size image and thumbnail (on a section, category list, etc.), besides of its normal view on an article page.

For example, one of my galleries made by hand and made by Textpattern.

Similar problem with <txp:article_image />, although in an article context I would like an additional custom field, next to an [Article image] ID (perhaps normally hidden by Ajax, with a visible “[x] Linked?” checkbox only).

Most likely this is just because lack of my knowledge and experience with Textpattern, could you hint me some another approach without plugins and programming?

Offline

#2 2013-09-13 16:01:21

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: <txp:image id="" link="" />

I know you said no plugins but you could use smd_macro to create a tag to do what you’re looking for.

Plain txp option:

<a href="<txp:custom_field name='imagelink'/>"><txp:article_image/></a>

My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#3 2013-09-13 19:04:39

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

Re: <txp:image id="" link="" />

Similar problem with <txp:article_image />, although in an article context I would like an additional custom field, next to an [Article image] ID (perhaps normally hidden by Ajax, with a visible “[x] Linked?” checkbox only).

All this you can do thanks to the combination of two plugins: bot_write_tab_customize (for me part of a standard installation) and glz_custom_fields (I would like to know the link of the newest version).

Offline

#4 2013-09-13 19:11:43

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

Re: <txp:image id="" link="" />

For example:

Create a checkbox custom field with the name “Linked” and a value “no”. Then:

<txp:if_custom_field name="Linked" value="no">
	<!-- Code for only thumbnail -->
<txp:else />
	<!-- Code for thumbnail with link to the image -->
</txp:if_custom_field>

Offline

#5 2013-09-13 19:14:54

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

Re: <txp:image id="" link="" />

The code for the one version of a linked thumbnail.

Offline

#6 2013-09-15 16:23:15

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

Re: <txp:image id="" link="" />

Awesome. Thanks Matt and Gug, very interesting plugins.

I have made also a few of workarounds, with some luck. The first makes linked gallery, in addition to an article_image:

<txp:images id='<txp:custom_field name="article_image" />'
  limit="11" offset="1" break="" wraptag="p" class="mygallery">
<txp:thumbnail link="1" poplink="1" /></txp:images>
<txp:article_image html_id="main" class="classic" />

All images there are rendering correctly, thanks GugUser for code correction.

The second code does not link an article_image, as intended — perhaps because the if_variable searches for exact value, not for “contains”:

<txp:variable name="alt-url" value='<txp:image_info type="alt" />' />
<txp:if_variable name="alt-url" value="://">
  <txp:images auto_detect="article">
    <a href="<txp:image_info type='alt' />">
      <img src="<txp:image_url />"
       alt="<txp:image_info type='caption' />"
       title="<txp:image_info type='caption' />" />
    </a>
  </txp:images>
<txp:else />
<txp:article_image />
</txp:if_variable>

Substitution Alt field for URL helped, but I found no way to avoid linking if the field is empty o verbal, without PHP if progamming:

<txp:images>
  <a href="<txp:image_info type='alt' />">
    <img src="<txp:image_url />"
     alt="<txp:image_info type='caption' />"
     title="<txp:image_info type='caption' />"
     border="0" />
  </a>
</txp:images>

I am still wondering why there is no such URL field for image description — simple, cheap, and very useful image attribute for everyday tasks.

Last edited by Vienuolis (2013-09-15 19:32:26)

Offline

#7 2013-09-15 16:54:47

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

Re: <txp:image id="" link="" />

I see general errors in your codes:

Problems related to closing tags, in your first expample (…) class="mygallery" /> where you don’t need to close, or in the second example I can’t see where <txp:if_variable> is closed, and more similar things.

Offline

#8 2013-09-15 18:24:09

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 307
Website GitHub GitLab Twitter

Re: <txp:image id="" link="" />

Thank you, GugUser, for correction — the first trick is valid now, and I hope it should be quite useful.

Offline

#9 2013-09-15 19:41:18

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

Re: <txp:image id="" link="" />

Vienuolis wrote:

I found no way to avoid linking if the field is empty o verbal, without PHP if progamming

You can try this:

<txp:etc_query data='<txp:images>
  <a href="<txp:image_info type=''alt'' />">
    <img src="<txp:image_url />"
     alt="<txp:image_info type=''caption'' />"
     title="<txp:image_info type=''caption'' />"
     border="0" />
  </a>
</txp:images>'
replace="//a[not(starts-with(@href, 'http://'))]&={node()}" />

Edit: sorry for a typo: must be {node()}.

Last edited by etc (2013-09-16 11:18:45)

Offline

Board footer

Powered by FluxBB