Fix file existence logic for get_avatar MACRO

Test for existence on filesystem
This commit is contained in:
Roan Horning 2022-08-01 20:19:44 -04:00
parent d4e8422677
commit 83d9156f17
Signed by untrusted user: rho_n
GPG Key ID: 234AEF20B72D5769
4 changed files with 8 additions and 5 deletions

View File

@ -32,7 +32,7 @@
<!--% this_host = hosts.$id %--> <!--% this_host = hosts.$id %-->
<h2 class="title">Correspondent</h2> <h2 class="title">Correspondent</h2>
<h2><!--% this_host.host %--></h2> <h2><!--% this_host.host %--></h2>
<p><img src="./images/<!--% get_avatar(this_host.local_image, this_host.hostid) %-->" <p><img src="./images/<!--% get_avatar(this_host.hostid) %-->"
height="80" alt="Host Image" /><br> height="80" alt="Host Image" /><br>
<label>Host ID</label>: <!--% this_host.hostid %--><br><br> <label>Host ID</label>: <!--% this_host.hostid %--><br><br>
<label>email:</label> <u><!--% this_host.email %--></u><br> <label>email:</label> <u><!--% this_host.email %--></u><br>

View File

@ -17,7 +17,7 @@
on h.hostid = e.hostid ' on h.hostid = e.hostid '
) %--> ) %-->
<tr height="80" bgcolor="#CCCCCC"> <tr height="80" bgcolor="#CCCCCC">
<td><img src="./images/<!--% get_avatar(host.local_image, host.hostid) %-->" height="80" width="80" alt="avatar" /></td> <td><img src="./images/<!--% get_avatar(host.hostid) %-->" height="80" width="80" alt="avatar" /></td>
<td><strong><!--% host.host %--></strong><br /> <td><strong><!--% host.host %--></strong><br />

View File

@ -1,4 +1,5 @@
<!--% PROCESS 'shared-avatar.tpl.html' %--> <!--% PROCESS 'shared-avatar.tpl.html' %-->
<!--% PROCESS 'shared-utils.tpl.html' %-->
<hr> <hr>
<article> <article>
<header> <header>
@ -46,7 +47,7 @@
<header> <header>
<h1><a href="episodes/hpr<!--% latest_episodes.id %-->.html">hpr<!--% latest_episodes.id %--> :: <!--% latest_episodes.title %--></a></h1> <h1><a href="episodes/hpr<!--% latest_episodes.id %-->.html">hpr<!--% latest_episodes.id %--> :: <!--% latest_episodes.title %--></a></h1>
<h3><!--% latest_episodes.summary%--></h3> <h3><!--% latest_episodes.summary%--></h3>
<p class="meta"$><img src="./images/<!--% get_avatar(latest_episodes.local_image, latest_episodes.hostid) %-->" height="80" width="80" alt="" /></a><br>Hosted by <a href="correspondents/host<!--% latest_episodes.host_id %-->.html"><!--% latest_episodes.host %--></a> on <!--% latest_episodes.date %--> is flagged as <!--% latest_episodes.explicit %--> and released under a <!--% latest_episodes.license %--> license. <br> <p class="meta"$><img src="./images/<!--% get_avatar(latest_episodes.hostid) %-->" height="80" width="80" alt="" /></a><br>Hosted by <a href="correspondents/<!--% zero_pad_left(latest_episodes.host_id) %-->/index.html"><!--% latest_episodes.host %--></a> on <!--% latest_episodes.date %--> is flagged as <!--% latest_episodes.explicit %--> and released under a <!--% latest_episodes.license %--> license. <br>
<strong>Tags:</strong> <!--% latest_episodes.tags %--><em></em>.<br> <strong>Tags:</strong> <!--% latest_episodes.tags %--><em></em>.<br>
<small>listen in <a href="local/hpr<!--% latest_episodes.id %-->.ogg">ogg</a>, <a href="local/hpr<!--% latest_episodes.id %-->.spx">spx</a>, or <a href="local/hpr<!--% latest_episodes.id %-->.mp3">mp3</a> format. <!--% show_series(latest_episodes.series) %--> <small>listen in <a href="local/hpr<!--% latest_episodes.id %-->.ogg">ogg</a>, <a href="local/hpr<!--% latest_episodes.id %-->.spx">spx</a>, or <a href="local/hpr<!--% latest_episodes.id %-->.mp3">mp3</a> format. <!--% show_series(latest_episodes.series) %-->
<a href="eps.php?id=3628#comments">comments (0)</a></small> <a href="eps.php?id=3628#comments">comments (0)</a></small>

View File

@ -1,3 +1,5 @@
<!--% MACRO get_avatar(has_avatar, host_id) BLOCK %--> <!--% MACRO get_avatar(host_id) BLOCK %-->
<!--% IF has_avatar == 0 %-->hpr_logo.png<!--% ELSE %-->hosts/<!--% host_id %-->.png<!--% END %--> <!--% TRY %-->
<!--% USE File ("./public_html/images/hosts/${host_id}.png") %-->hosts/<!--% File.name %-->
<!--% CATCH File %-->hpr_logo.png<!--% END %-->
<!--% END %--> <!--% END %-->