<!DOCTYPE html>
<html lang='en'>
<head>
<title>textile « plugins « doc - ikiwiki-upstream - Unnamed repository; edit this file to name it for gitweb.</title>
<meta name='generator' content='cgit v1.2.3'/>
<meta name='robots' content='index, nofollow'/>
<link rel='stylesheet' type='text/css' href='/cgit-css/cgit.css'/>
<link rel='stylesheet' type='text/css' href='/cgit-local/local.css'/>
<script type='text/javascript' src='/cgit.js'></script>
<link rel='shortcut icon' href='/favicon.ico'/>
<link rel='alternate' title='Atom feed' href='https://source.jones.dk/ikiwiki-upstream/atom/doc/plugins/textile?h=master' type='application/atom+xml'/>
<link rel='vcs-git' href='https://source.jones.dk/ikiwiki-upstream' title='ikiwiki-upstream Git repository'/>
<link rel='vcs-git' href='user@source.jones.dk:ikiwiki-upstream' title='ikiwiki-upstream Git repository'/>
</head>
<body>
<div id='cgit'><table id='header'>
<tr>
<td class='logo' rowspan='2'><a href='/'><img src='/cgit-css/cgit.png' alt='cgit logo'/></a></td>
<td class='main'><a href='/'>index</a> : <a href='/ikiwiki-upstream/'>ikiwiki-upstream</a></td><td class='form'><form method='get'>
<input type='hidden' name='id' value='61c2030b2db03d2a83a210b2784fe25246c0be42'/><select name='h' onchange='this.form.submit();'>
<option value='layoutgala'>layoutgala</option>
<option value='master' selected='selected'>master</option>
</select> <input type='submit' value='switch'/></form></td></tr>
<tr><td class='sub'>Unnamed repository; edit this file to name it for gitweb.</td><td class='sub right'>Jonas Smedegaard</td></tr></table>
<table class='tabs'><tr><td>
<a href='/ikiwiki-upstream/'>summary</a><a href='/ikiwiki-upstream/refs/?id=61c2030b2db03d2a83a210b2784fe25246c0be42'>refs</a><a href='/ikiwiki-upstream/log/doc/plugins/textile'>log</a><a class='active' href='/ikiwiki-upstream/tree/doc/plugins/textile?id=61c2030b2db03d2a83a210b2784fe25246c0be42'>tree</a><a href='/ikiwiki-upstream/commit/doc/plugins/textile?id=61c2030b2db03d2a83a210b2784fe25246c0be42'>commit</a><a href='/ikiwiki-upstream/diff/doc/plugins/textile?id=61c2030b2db03d2a83a210b2784fe25246c0be42'>diff</a></td><td class='form'><form class='right' method='get' action='/ikiwiki-upstream/log/doc/plugins/textile'>
<input type='hidden' name='id' value='61c2030b2db03d2a83a210b2784fe25246c0be42'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/ikiwiki-upstream/tree/?id=61c2030b2db03d2a83a210b2784fe25246c0be42'>root</a>/<a href='/ikiwiki-upstream/tree/doc?id=61c2030b2db03d2a83a210b2784fe25246c0be42'>doc</a>/<a href='/ikiwiki-upstream/tree/doc/plugins?id=61c2030b2db03d2a83a210b2784fe25246c0be42'>plugins</a>/<a href='/ikiwiki-upstream/tree/doc/plugins/textile?id=61c2030b2db03d2a83a210b2784fe25246c0be42'>textile</a></div><div class='content'><table summary='tree listing' class='list'>
<tr class='nohover'><th class='left'>Mode</th><th class='left'>Name</th><th class='right'>Size</th><th/></tr>
<tr><td class='ls-mode'>-rw-r--r--</td><td><a class='ls-blob mdwn' href='/ikiwiki-upstream/tree/doc/plugins/te<ol class="hl">
<li id="n_1" class="hl"><span class="hl slc">#!/usr/bin/perl</span></li>
<li id="n_2" class="hl"><span class="hl slc">#&nbsp;Ikiwiki enhanced image handling plugin</span></li>
<li id="n_3" class="hl"><span class="hl slc"># Christian Mock cm&#64;tahina.priv.at 20061002</span></li>
<li id="n_4" class="hl"><span class="hl kwa">package </span>IkiWiki<span class="hl opt">::</span>Plugin<span class="hl opt">::</span>img<span class="hl opt">;</span></li>
<li id="n_5" class="hl"></li>
<li id="n_6" class="hl"><span class="hl kwa">use </span>warnings<span class="hl opt">;</span></li>
<li id="n_7" class="hl"><span class="hl kwa">use </span>strict<span class="hl opt">;</span></li>
<li id="n_8" class="hl"><span class="hl kwa">use </span>IkiWiki <span class="hl num">2.00</span><span class="hl opt">;</span></li>
<li id="n_9" class="hl"></li>
<li id="n_10" class="hl"><span class="hl kwc">my </span><span class="hl kwb">%imgdefaults</span><span class="hl opt">;</span></li>
<li id="n_11" class="hl"></li>
<li id="n_12" class="hl"><span class="hl kwa">sub </span>import <span class="hl opt">{ </span><span class="hl slc">#{{{</span></li>
<li id="n_13" class="hl">    hook<span class="hl opt">(</span>type <span class="hl opt">=&gt; </span><span class="hl sng">&quot;preprocess&quot;</span><span class="hl opt">, </span>id <span class="hl opt">=&gt; </span><span class="hl sng">&quot;img&quot;</span><span class="hl opt">, </span>call <span class="hl opt">=&gt; </span>\<span class="hl opt">&amp;</span>preprocess<span class="hl opt">, </span>scan <span class="hl opt">=&gt; </span><span class="hl num">1</span><span class="hl opt">);</span></li>
<li id="n_14" class="hl"><span class="hl opt">} </span><span class="hl slc">#}}}</span></li>
<li id="n_15" class="hl"></li>
<li id="n_16" class="hl"><span class="hl kwa">sub </span>preprocess <span class="hl opt">(&#64;) { </span><span class="hl slc">#{{{</span></li>
<li id="n_17" class="hl">    <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$image</span><span class="hl opt">) = </span><span class="hl kwb">$_</span><span class="hl opt">[</span><span class="hl num">0</span><span class="hl opt">] =~ </span><span class="hl kwd">/$config{wiki_file_regexp}/</span><span class="hl opt">; </span><span class="hl slc"># untaint</span></li>
<li id="n_18" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">%params</span><span class="hl opt">=</span><span class="hl kwb">&#64;_</span><span class="hl opt">;</span></li>
<li id="n_19" class="hl"></li>
<li id="n_20" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(! </span><span class="hl kwc">exists </span><span class="hl kwb">$imgdefaults</span><span class="hl opt">{</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}}) {</span></li>
<li id="n_21" class="hl">        <span class="hl kwb">$imgdefaults</span><span class="hl opt">{</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}} = {};</span></li>
<li id="n_22" class="hl">    <span class="hl opt">}</span></li>
<li id="n_23" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$size </span><span class="hl opt">= </span><span class="hl kwb">$params</span><span class="hl opt">{</span>size<span class="hl opt">} || </span><span class="hl kwb">$imgdefaults</span><span class="hl opt">{</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}}-&gt;{</span>size<span class="hl opt">} || </span><span class="hl sng">&#39;full&#39;</span><span class="hl opt">;</span></li>
<li id="n_24" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$alt </span><span class="hl opt">= </span><span class="hl kwb">$params</span><span class="hl opt">{</span>alt<span class="hl opt">} || </span><span class="hl kwb">$imgdefaults</span><span class="hl opt">{</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}}-&gt;{</span>alt<span class="hl opt">} || </span><span class="hl sng">&#39;&#39;</span><span class="hl opt">;</span></li>
<li id="n_25" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$title </span><span class="hl opt">= </span><span class="hl kwb">$params</span><span class="hl opt">{</span>title<span class="hl opt">} || </span><span class="hl kwb">$imgdefaults</span><span class="hl opt">{</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}}-&gt;{</span>title<span class="hl opt">} || </span><span class="hl sng">&#39;&#39;</span><span class="hl opt">;</span></li>
<li id="n_26" class="hl"></li>
<li id="n_27" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$image </span><span class="hl kwc">eq </span><span class="hl sng">&#39;defaults&#39;</span><span class="hl opt">) {</span></li>
<li id="n_28" class="hl">        <span class="hl kwb">$imgdefaults</span><span class="hl opt">{</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}} = {</span></li>
<li id="n_29" class="hl">            size <span class="hl opt">=&gt; </span><span class="hl kwb">$size</span><span class="hl opt">,</span></li>
<li id="n_30" class="hl">            alt <span class="hl opt">=&gt; </span><span class="hl kwb">$alt</span><span class="hl opt">,</span></li>
<li id="n_31" class="hl">            title <span class="hl opt">=&gt; </span><span class="hl kwb">$title</span><span class="hl opt">,</span></li>
<li id="n_32" class="hl">        <span class="hl opt">};</span></li>
<li id="n_33" class="hl">        <span class="hl kwa">return </span><span class="hl sng">&#39;&#39;</span><span class="hl opt">;</span></li>
<li id="n_34" class="hl">    <span class="hl opt">}</span></li>
<li id="n_35" class="hl"></li>
<li id="n_36" class="hl">    <span class="hl kwc">push </span><span class="hl opt">&#64;{</span><span class="hl kwb">$links</span><span class="hl opt">{</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}}}, </span><span class="hl kwb">$image</span><span class="hl opt">;</span></li>
<li id="n_37" class="hl">    <span class="hl slc"># optimisation: detect scan mode, and avoid generating the image</span></li>
<li id="n_38" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(! </span><span class="hl kwc">defined wantarray</span><span class="hl opt">) {</span></li>
<li id="n_39" class="hl">        <span class="hl kwa">return</span><span class="hl opt">;</span></li>
<li id="n_40" class="hl">    <span class="hl opt">}</span></li>
<li id="n_41" class="hl"></li>
<li id="n_42" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$file </span><span class="hl opt">= </span>bestlink<span class="hl opt">(</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}, </span><span class="hl kwb">$image</span><span class="hl opt">);</span></li>
<li id="n_43" class="hl"></li>
<li id="n_44" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$dir </span><span class="hl opt">= </span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">};</span></li>
<li id="n_45" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$base </span><span class="hl opt">= </span>IkiWiki<span class="hl opt">::</span>basename<span class="hl opt">(</span><span class="hl kwb">$file</span><span class="hl opt">);</span></li>
<li id="n_46" class="hl"></li>
<li id="n_47" class="hl">    <span class="hl kwc">eval </span><span class="hl sng">q{use Image::Magick}</span><span class="hl opt">;</span></li>
<li id="n_48" class="hl">    error<span class="hl opt">(</span><span class="hl kwb">$&#64;</span><span class="hl opt">) </span><span class="hl kwa">if </span><span class="hl kwb">$&#64;</span><span class="hl opt">;</span></li>
<li id="n_49" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$im </span><span class="hl opt">= </span>Image<span class="hl opt">::</span>Magick-<span class="hl opt">&gt;</span><span class="hl kwd">new</span><span class="hl opt">;</span></li>
<li id="n_50" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$imglink</span><span class="hl opt">;</span></li>
<li id="n_51" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$r</span><span class="hl opt">;</span></li>
<li id="n_52" class="hl"></li>
<li id="n_53" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(</span><span class="hl kwb">$size </span><span class="hl kwc">ne </span><span class="hl sng">&#39;full&#39;</span><span class="hl opt">) {</span></li>
<li id="n_54" class="hl">        <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$w</span><span class="hl opt">, </span><span class="hl kwb">$h</span><span class="hl opt">) = (</span><span class="hl kwb">$size </span><span class="hl opt">=~ </span><span class="hl kwd">/^(\d+)x(\d+)$/</span><span class="hl opt">);</span></li>
<li id="n_55" class="hl">        <span class="hl kwa">return </span><span class="hl sng">&quot;[[img &quot;</span><span class="hl opt">.</span><span class="hl kwc">sprintf</span><span class="hl opt">(</span>gettext<span class="hl opt">(</span><span class="hl sng">&#39;bad size &quot;</span><span class="hl ipl">%s</span><span class="hl sng">&quot;&#39;</span><span class="hl opt">), </span><span class="hl kwb">$size</span><span class="hl opt">).</span><span class="hl sng">&quot;]]&quot;</span></li>
<li id="n_56" class="hl">            <span class="hl kwa">unless </span><span class="hl opt">(</span><span class="hl kwc">defined </span><span class="hl kwb">$w </span><span class="hl opt">&amp;&amp; </span><span class="hl kwc">defined </span><span class="hl kwb">$h</span><span class="hl opt">);</span></li>
<li id="n_57" class="hl"></li>
<li id="n_58" class="hl">        <span class="hl kwc">my </span><span class="hl kwb">$outfile </span><span class="hl opt">= </span><span class="hl sng">&quot;</span><span class="hl ipl">$config</span><span class="hl sng">{destdir}/</span><span class="hl ipl">$dir/$</span><span class="hl sng">{w}x${h}-</span><span class="hl ipl">$base</span><span class="hl sng">&quot;</span><span class="hl opt">;</span></li>
<li id="n_59" class="hl">        <span class="hl kwb">$imglink </span><span class="hl opt">= </span><span class="hl sng">&quot;</span><span class="hl ipl">$dir/$</span><span class="hl sng">{w}x${h}-</span><span class="hl ipl">$base</span><span class="hl sng">&quot;</span><span class="hl opt">;</span></li>
<li id="n_60" class="hl">        </li>
<li id="n_61" class="hl">        will_render<span class="hl opt">(</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}, </span><span class="hl kwb">$imglink</span><span class="hl opt">);</span></li>
<li id="n_62" class="hl"></li>
<li id="n_63" class="hl">        <span class="hl kwa">if </span><span class="hl opt">(-</span>e <span class="hl kwb">$outfile </span><span class="hl opt">&amp;&amp; (-</span>M srcfile<span class="hl opt">(</span><span class="hl kwb">$file</span><span class="hl opt">) &gt;= -</span>M <span class="hl kwb">$outfile</span><span class="hl opt">)) {</span></li>
<li id="n_64" class="hl">            <span class="hl kwb">$r </span><span class="hl opt">= </span><span class="hl kwb">$im</span><span class="hl opt">-&gt;</span><span class="hl kwd">Read</span><span class="hl opt">(</span><span class="hl kwb">$outfile</span><span class="hl opt">);</span></li>
<li id="n_65" class="hl">            <span class="hl kwa">return </span><span class="hl sng">&quot;[[img &quot;</span><span class="hl opt">.</span><span class="hl kwc">sprintf</span><span class="hl opt">(</span>gettext<span class="hl opt">(</span><span class="hl sng">&quot;failed to read </span><span class="hl ipl">%s</span><span class="hl sng">: </span><span class="hl ipl">%s</span><span class="hl sng">&quot;</span><span class="hl opt">), </span><span class="hl kwb">$outfile</span><span class="hl opt">, </span><span class="hl kwb">$r</span><span class="hl opt">).</span><span class="hl sng">&quot;]]&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$r</span><span class="hl opt">;</span></li>
<li id="n_66" class="hl">        <span class="hl opt">}</span></li>
<li id="n_67" class="hl">        <span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_68" class="hl">            <span class="hl kwb">$r </span><span class="hl opt">= </span><span class="hl kwb">$im</span><span class="hl opt">-&gt;</span><span class="hl kwd">Read</span><span class="hl opt">(</span>srcfile<span class="hl opt">(</span><span class="hl kwb">$file</span><span class="hl opt">));</span></li>
<li id="n_69" class="hl">            <span class="hl kwa">return </span><span class="hl sng">&quot;[[img &quot;</span><span class="hl opt">.</span><span class="hl kwc">sprintf</span><span class="hl opt">(</span>gettext<span class="hl opt">(</span><span class="hl sng">&quot;failed to read </span><span class="hl ipl">%s</span><span class="hl sng">: </span><span class="hl ipl">%s</span><span class="hl sng">&quot;</span><span class="hl opt">), </span><span class="hl kwb">$file</span><span class="hl opt">, </span><span class="hl kwb">$r</span><span class="hl opt">).</span><span class="hl sng">&quot;]]&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$r</span><span class="hl opt">;</span></li>
<li id="n_70" class="hl"></li>
<li id="n_71" class="hl">            <span class="hl kwb">$r </span><span class="hl opt">= </span><span class="hl kwb">$im</span><span class="hl opt">-&gt;</span><span class="hl kwd">Resize</span><span class="hl opt">(</span>geometry <span class="hl opt">=&gt; </span><span class="hl sng">&quot;${w}x${h}&quot;</span><span class="hl opt">);</span></li>
<li id="n_72" class="hl">            <span class="hl kwa">return </span><span class="hl sng">&quot;[[img &quot;</span><span class="hl opt">.</span><span class="hl kwc">sprintf</span><span class="hl opt">(</span>gettext<span class="hl opt">(</span><span class="hl sng">&quot;failed to resize: </span><span class="hl ipl">%s</span><span class="hl sng">&quot;</span><span class="hl opt">), </span><span class="hl kwb">$r</span><span class="hl opt">).</span><span class="hl sng">&quot;]]&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$r</span><span class="hl opt">;</span></li>
<li id="n_73" class="hl"></li>
<li id="n_74" class="hl">            <span class="hl slc"># don&#39;t actually write file in preview mode</span></li>
<li id="n_75" class="hl">            <span class="hl kwa">if </span><span class="hl opt">(! </span><span class="hl kwb">$params</span><span class="hl opt">{</span>preview<span class="hl opt">}) {</span></li>
<li id="n_76" class="hl">                <span class="hl kwc">my </span><span class="hl kwb">&#64;blob </span><span class="hl opt">= </span><span class="hl kwb">$im</span><span class="hl opt">-&gt;</span><span class="hl kwd">ImageToBlob</span><span class="hl opt">();</span></li>
<li id="n_77" class="hl">                writefile<span class="hl opt">(</span><span class="hl kwb">$imglink</span><span class="hl opt">, </span><span class="hl kwb">$config</span><span class="hl opt">{</span>destdir<span class="hl opt">}, </span><span class="hl kwb">$blob</span><span class="hl opt">[</span><span class="hl num">0</span><span class="hl opt">], </span><span class="hl num">1</span><span class="hl opt">);</span></li>
<li id="n_78" class="hl">            <span class="hl opt">}</span></li>
<li id="n_79" class="hl">            <span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_80" class="hl">                <span class="hl kwb">$imglink </span><span class="hl opt">= </span><span class="hl kwb">$file</span><span class="hl opt">;</span></li>
<li id="n_81" class="hl">            <span class="hl opt">}</span></li>
<li id="n_82" class="hl">        <span class="hl opt">}</span></li>
<li id="n_83" class="hl">    <span class="hl opt">}</span></li>
<li id="n_84" class="hl">    <span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_85" class="hl">        <span class="hl kwb">$r </span><span class="hl opt">= </span><span class="hl kwb">$im</span><span class="hl opt">-&gt;</span><span class="hl kwd">Read</span><span class="hl opt">(</span>srcfile<span class="hl opt">(</span><span class="hl kwb">$file</span><span class="hl opt">));</span></li>
<li id="n_86" class="hl">        <span class="hl kwa">return </span><span class="hl sng">&quot;[[img &quot;</span><span class="hl opt">.</span><span class="hl kwc">sprintf</span><span class="hl opt">(</span>gettext<span class="hl opt">(</span><span class="hl sng">&quot;failed to read </span><span class="hl ipl">%s</span><span class="hl sng">: </span><span class="hl ipl">%s</span><span class="hl sng">&quot;</span><span class="hl opt">), </span><span class="hl kwb">$file</span><span class="hl opt">, </span><span class="hl kwb">$r</span><span class="hl opt">).</span><span class="hl sng">&quot;]]&quot;</span> <span class="hl kwa">if </span><span class="hl kwb">$r</span><span class="hl opt">;</span></li>
<li id="n_87" class="hl">        <span class="hl kwb">$imglink </span><span class="hl opt">= </span><span class="hl kwb">$file</span><span class="hl opt">;</span></li>
<li id="n_88" class="hl">    <span class="hl opt">}</span></li>
<li id="n_89" class="hl"></li>
<li id="n_90" class="hl">    add_depends<span class="hl opt">(</span><span class="hl kwb">$imglink</span><span class="hl opt">, </span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">});</span></li>
<li id="n_91" class="hl"></li>
<li id="n_92" class="hl">    <span class="hl kwc">my </span><span class="hl opt">(</span><span class="hl kwb">$fileurl</span><span class="hl opt">, </span><span class="hl kwb">$imgurl</span><span class="hl opt">);</span></li>
<li id="n_93" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(! </span><span class="hl kwb">$params</span><span class="hl opt">{</span>preview<span class="hl opt">}) {</span></li>
<li id="n_94" class="hl">        <span class="hl kwb">$fileurl</span><span class="hl opt">=</span>urlto<span class="hl opt">(</span><span class="hl kwb">$file</span><span class="hl opt">, </span><span class="hl kwb">$params</span><span class="hl opt">{</span>destpage<span class="hl opt">});</span></li>
<li id="n_95" class="hl">        <span class="hl kwb">$imgurl</span><span class="hl opt">=</span>urlto<span class="hl opt">(</span><span class="hl kwb">$imglink</span><span class="hl opt">, </span><span class="hl kwb">$params</span><span class="hl opt">{</span>destpage<span class="hl opt">});</span></li>
<li id="n_96" class="hl">    <span class="hl opt">}</span></li>
<li id="n_97" class="hl">    <span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_98" class="hl">        <span class="hl kwb">$fileurl</span><span class="hl opt">=</span><span class="hl sng">&quot;</span><span class="hl ipl">$config</span><span class="hl sng">{url}/</span><span class="hl ipl">$file</span><span class="hl sng">&quot;</span><span class="hl opt">;</span></li>
<li id="n_99" class="hl">        <span class="hl kwb">$imgurl</span><span class="hl opt">=</span><span class="hl sng">&quot;</span><span class="hl ipl">$config</span><span class="hl sng">{url}/</span><span class="hl ipl">$imglink</span><span class="hl sng">&quot;</span><span class="hl opt">;</span></li>
<li id="n_100" class="hl">    <span class="hl opt">}</span></li>
<li id="n_101" class="hl"></li>
<li id="n_102" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(! </span><span class="hl kwc">defined</span><span class="hl opt">(</span><span class="hl kwb">$im</span><span class="hl opt">-&gt;</span><span class="hl kwd">Get</span><span class="hl opt">(</span><span class="hl sng">&quot;width&quot;</span><span class="hl opt">)) || ! </span><span class="hl kwc">defined</span><span class="hl opt">(</span><span class="hl kwb">$im</span><span class="hl opt">-&gt;</span><span class="hl kwd">Get</span><span class="hl opt">(</span><span class="hl sng">&quot;height&quot;</span><span class="hl opt">))) {</span></li>
<li id="n_103" class="hl">        <span class="hl kwa">return </span><span class="hl sng">&quot;[[img &quot;</span><span class="hl opt">.</span><span class="hl kwc">sprintf</span><span class="hl opt">(</span>gettext<span class="hl opt">(</span><span class="hl sng">&quot;failed to determine size of image </span><span class="hl ipl">%s</span><span class="hl sng">&quot;</span><span class="hl opt">), </span><span class="hl kwb">$file</span><span class="hl opt">).</span><span class="hl sng">&quot;]]&quot;</span><span class="hl opt">;</span></li>
<li id="n_104" class="hl">    <span class="hl opt">}</span></li>
<li id="n_105" class="hl"></li>
<li id="n_106" class="hl">    <span class="hl kwc">my </span><span class="hl kwb">$imgtag</span><span class="hl opt">=</span><span class="hl sng">&#39;&lt;img src=&quot;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$imgurl</span><span class="hl opt">.</span></li>
<li id="n_107" class="hl">        <span class="hl sng">&#39;&quot; alt=&quot;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$alt</span><span class="hl opt">.</span><span class="hl sng">&#39;&quot; width=&quot;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$im</span><span class="hl opt">-&gt;</span><span class="hl kwd">Get</span><span class="hl opt">(</span><span class="hl sng">&quot;width&quot;</span><span class="hl opt">).</span></li>
<li id="n_108" class="hl">        <span class="hl sng">&#39;&quot; height=&quot;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$im</span><span class="hl opt">-&gt;</span><span class="hl kwd">Get</span><span class="hl opt">(</span><span class="hl sng">&quot;height&quot;</span><span class="hl opt">).</span><span class="hl sng">&#39;&quot;&#39;</span><span class="hl opt">.</span></li>
<li id="n_109" class="hl">        <span class="hl opt">(</span><span class="hl kwc">defined </span><span class="hl kwb">$title </span><span class="hl opt">? </span><span class="hl sng">&#39; title=&quot;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$title</span><span class="hl opt">.</span><span class="hl sng">&#39;&quot;&#39;</span> <span class="hl opt">: </span><span class="hl sng">&#39;&#39;</span><span class="hl opt">).</span></li>
<li id="n_110" class="hl">        <span class="hl opt">(</span><span class="hl kwc">exists </span><span class="hl kwb">$params</span><span class="hl opt">{</span><span class="hl kwa">class</span><span class="hl opt">} ? </span><span class="hl sng">&#39; class=&quot;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$params</span><span class="hl opt">{</span><span class="hl kwa">class</span><span class="hl opt">}.</span><span class="hl sng">&#39;&quot;&#39;</span> <span class="hl opt">: </span><span class="hl sng">&#39;&#39;</span><span class="hl opt">).</span></li>
<li id="n_111" class="hl">        <span class="hl opt">(</span><span class="hl kwc">exists </span><span class="hl kwb">$params</span><span class="hl opt">{</span>id<span class="hl opt">} ? </span><span class="hl sng">&#39; id=&quot;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$params</span><span class="hl opt">{</span>id<span class="hl opt">}.</span><span class="hl sng">&#39;&quot;&#39;</span> <span class="hl opt">: </span><span class="hl sng">&#39;&#39;</span><span class="hl opt">).</span></li>
<li id="n_112" class="hl">        <span class="hl sng">&#39; /&gt;&#39;</span><span class="hl opt">;</span></li>
<li id="n_113" class="hl"></li>
<li id="n_114" class="hl">    <span class="hl kwa">if </span><span class="hl opt">(! </span><span class="hl kwc">defined </span><span class="hl kwb">$params</span><span class="hl opt">{</span><span class="hl kwc">link</span><span class="hl opt">} || </span><span class="hl kwc">lc</span><span class="hl opt">(</span><span class="hl kwb">$params</span><span class="hl opt">{</span><span class="hl kwc">link</span><span class="hl opt">}) </span><span class="hl kwc">eq </span><span class="hl sng">&#39;yes&#39;</span><span class="hl opt">) {</span></li>
<li id="n_115" class="hl">        <span class="hl kwa">return  </span><span class="hl sng">&#39;&lt;a href=&quot;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$fileurl</span><span class="hl opt">.</span><span class="hl sng">&#39;&quot;&gt;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$imgtag</span><span class="hl opt">.</span><span class="hl sng">&#39;&lt;/a&gt;&#39;</span><span class="hl opt">;</span></li>
<li id="n_116" class="hl">    <span class="hl opt">}</span></li>
<li id="n_117" class="hl">    <span class="hl kwa">elsif </span><span class="hl opt">(</span><span class="hl kwb">$params</span><span class="hl opt">{</span><span class="hl kwc">link</span><span class="hl opt">} =~ </span><span class="hl kwd">/^\w+:\/</span>\<span class="hl kwd">//</span><span class="hl opt">) {</span></li>
<li id="n_118" class="hl">        <span class="hl kwa">return  </span><span class="hl sng">&#39;&lt;a href=&quot;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$params</span><span class="hl opt">{</span><span class="hl kwc">link</span><span class="hl opt">}.</span><span class="hl sng">&#39;&quot;&gt;&#39;</span><span class="hl opt">.</span><span class="hl kwb">$imgtag</span><span class="hl opt">.</span><span class="hl sng">&#39;&lt;/a&gt;&#39;</span><span class="hl opt">;</span></li>
<li id="n_119" class="hl">    <span class="hl opt">}</span></li>
<li id="n_120" class="hl">    <span class="hl kwa">elsif </span><span class="hl opt">(</span><span class="hl kwc">length </span>bestlink<span class="hl opt">(</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}, </span><span class="hl kwb">$params</span><span class="hl opt">{</span><span class="hl kwc">link</span><span class="hl opt">})) {</span></li>
<li id="n_121" class="hl">        add_depends<span class="hl opt">(</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}, </span><span class="hl kwb">$params</span><span class="hl opt">{</span><span class="hl kwc">link</span><span class="hl opt">});</span></li>
<li id="n_122" class="hl">        <span class="hl kwa">return </span>htmllink<span class="hl opt">(</span><span class="hl kwb">$params</span><span class="hl opt">{</span>page<span class="hl opt">}, </span><span class="hl kwb">$params</span><span class="hl opt">{</span>destpage<span class="hl opt">},</span></li>
<li id="n_123" class="hl">            <span class="hl kwb">$params</span><span class="hl opt">{</span><span class="hl kwc">link</span><span class="hl opt">}, </span>linktext <span class="hl opt">=&gt; </span><span class="hl kwb">$imgtag</span><span class="hl opt">,</span></li>
<li id="n_124" class="hl">            noimageinline <span class="hl opt">=&gt; </span><span class="hl num">1</span><span class="hl opt">);</span></li>
<li id="n_125" class="hl">    <span class="hl opt">}</span></li>
<li id="n_126" class="hl">    <span class="hl kwa">else </span><span class="hl opt">{</span></li>
<li id="n_127" class="hl">        <span class="hl kwa">return </span><span class="hl kwb">$imgtag</span><span class="hl opt">;</span></li>
<li id="n_128" class="hl">    <span class="hl opt">}</span></li>
<li id="n_129" class="hl"><span class="hl opt">} </span><span class="hl slc">#}}}</span></li>
<li id="n_130" class="hl"></li>
<li id="n_131" class="hl"><span class="hl num">1</span></li>
</ol></code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.46.0</a>) at 2025-05-28 10:34:37 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
