[tw5] how to $transclude image from second field if first field is empty or doesn't exist?

63 views
Skip to first unread message

sini-Kit

unread,
Jan 8, 2017, 2:21:33 AM1/8/17
to TiddlyWiki
Hi! I use this variant for text fields
<$view field="caption">
<$view field="title"/>
</$view>


but with images this variant don't work

Now I make new shop and every item has small image. so tiddler has field image150x150: images/Konteyner_Umnyy_kholodilnik_1_8_l_vysokiy_vid1.jpg
and every item has several big pictures, I attach them to my item by tag  <$list filter="[is[current]tagging[]type[image/jpeg]sort[title]]">.....

I want if people forget to put field image150x150 or make it empty to show first big image from my list <$list filter="[is[current]tagging[]type[image/jpeg]sort[title]nth[1]]">..

Now I found this variant for pictures

<$transclude field="image150x150" >
  <$list filter="[is[current]tagging[]type[image/jpeg]sort[title]nth[1]]"><$image  source= {{!!_canonical_uri}} alt={{!!alt}} /></$list>
</$transclude>

but in this variant field image150x150 must look like <$image  source="images/products/our_projects/first_gallery/small.jpg"/>  but I want this field look like images/products/our_projects/first_gallery/small.jpg

here is  new shop http://tupper.online/heeg.html#B29 with experimental pictures.


Tobias Beer

unread,
Jan 8, 2017, 9:11:32 AM1/8/17
to TiddlyWiki
Hi sini-Kit,

use the list widget for conditionals:

<$list filter="[all[current]has[image150x150]]">
...render image...
</$list>

<$list filter="[all[current]!has[image150x150]]">
...render fallback...
</$list>

Best wishes,

Tobias.

sini-Kit

unread,
Jan 8, 2017, 10:54:17 AM1/8/17
to TiddlyWiki
Thank you, Tobias! It is very simple and works good. I'll take it.

воскресенье, 8 января 2017 г., 17:11:32 UTC+3 пользователь Tobias Beer написал:
Reply all
Reply to author
Forward
0 new messages