tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/12068-image-for-listing-pageCascade CMS: Discussion 2015-06-22T19:44:47Ztag:help-archives.hannonhill.com,2010-02-09:Comment/371875662015-06-22T17:40:10Z2015-06-22T17:40:10ZImage for listing page<div><p>Hi Tony,</p>
<p>Using the <code>image</code> field, the following should output
an image if one is chosen for that field:</p>
<pre>
<code>#set ($imageField = $b.getStructuredDataNode("insert/image"))
#if(!$_PropertyTool.isNull($imageField.asset))
<img src="${imageField.asset.path}" alt="${_EscapeTool.xml($b.getStructuredDataNode("insert/alt").textValue)}"/>
#end</code>
</pre>
<p>Note: if you would like to make the image's src attribute a
cross-Site link, you can also append the Site name onto the
front:</p>
<pre>
<code><img src="site://${imageField.asset.siteName}/${imageField.asset.path}" alt="${_EscapeTool.xml($b.getStructuredDataNode("insert/alt").textValue)}"/></code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/371875662015-06-22T18:26:37Z2015-06-22T18:26:37ZImage for listing page<div><p>Ryan,</p>
<p>I used your code, but it didn’t work. It’s similar
to an example I tried that you had on: <a href="http://help.hannonhill.com/discussions/velocity-formats/11508-getting-image-path">
http://help.hannonhill.com/discussions/velocity-formats/11508-getti...</a>
.</p>
<p>Does $b need to be changed? I don’t think $b is referenced
anywhere else on the script. My loop is: #foreach($article in
$articles)</p>
<p>-Tony</p></div>Tony Jose Pontitag:help-archives.hannonhill.com,2010-02-09:Comment/371875662015-06-22T18:36:50Z2015-06-22T18:36:51ZImage for listing page<div><p>Ryan,</p>
<p>Please disregard my last email. I accidently deleted:<br>
#set($b = $_.locatePage($article.getChild("path").value))</p>
<p>It’s working great now. Sorry about the confusion. Thanks
for all your help.</p>
<p>-Tony</p>
<p>From: Tony Jose Ponti<br>
Sent: Monday, June 22, 2015 1:26 PM<br>
To: 'Ryan Griffith'<br>
Subject: RE: Image for listing page [Velocity Formats #12068]</p>
<p>Ryan,</p>
<p>I used your code, but it didn’t work. It’s similar
to an example I tried that you had on: <a href="http://help.hannonhill.com/discussions/velocity-formats/11508-getting-image-path">
http://help.hannonhill.com/discussions/velocity-formats/11508-getti...</a>
.</p>
<p>Does $b need to be changed? I don’t think $b is referenced
anywhere else on the script. My loop is: #foreach($article in
$articles)</p>
<p>-Tony</p></div>Tony Jose Pontitag:help-archives.hannonhill.com,2010-02-09:Comment/371875662015-06-22T19:44:45Z2015-06-22T19:44:45ZImage for listing page<div><p>Thank you for following up, Tony, I am glad to hear my proposed
change did the trick.</p>
<p>I'm going to go ahead and close this discussion, please feel
free to comment or reply to re-open if you have any additional
questions.</p>
<p>Have a great day!</p></div>Ryan Griffith