tags: $:/tags/Macro
title: $:/core/macros/image-picker
type: text/vnd.tiddlywiki

\procedure image-picker-thumbnail(actions)
<$button tag="a" tooltip=<<imageTitle>>><$transclude $variable="actions"/><$transclude tiddler=<<imageTitle>>/></$button>
\end

\procedure image-picker-list(filter,actions)
\whitespace trim
<$list filter=<<filter>> variable="imageTitle">
<$transclude $variable="image-picker-thumbnail" actions=<<actions>>/>
&#32;
</$list>
\end

\procedure image-picker(actions,filter:"[all[shadows+tiddlers]is[image]] -[type[application/pdf]] +[!has[draft.of]$subfilter$sort[title]]",subfilter:"")
\whitespace trim
<div class="tc-image-chooser">
<$let state-system=<<qualify "$:/state/image-picker/system">> tv-filter={{{ [<filter>search-replace[$subfilter$],<subfilter>] }}}>
<$checkbox tiddler=<<state-system>> field="text" checked="show" unchecked="hide" default="hide">
<span class="tc-tiny-gap-left">{{$:/language/SystemTiddlers/Include/Prompt}}</span>
</$checkbox>
<$reveal state=<<state-system>> type="match" text="hide" default="hide" tag="div">
<$transclude $variable="image-picker-list" filter=`$(tv-filter)$ +[!is[system]]` actions=<<actions>>/>
</$reveal>
<$reveal state=<<state-system>> type="nomatch" text="hide" default="hide" tag="div">
<$transclude $variable="image-picker-list" filter=<<tv-filter>> actions=<<actions>>/>
</$reveal>
</$let>
</div>
\end

\procedure image-picker-include-tagged-images(actions)
<$transclude $variable="image-picker" filter="[all[shadows+tiddlers]is[image]] [all[shadows+tiddlers]tag[$:/tags/Image]] -[type[application/pdf]] +[!has[draft.of]sort[title]]" actions=<<actions>>/>
\end
