Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT to display news item images with consistent size
    primarykey
    data
    text
    <p>I have a RSS XML news file, which contains a list of items inclusive of a URL to an image. I also have an associated XSLT.</p> <p>The problem is that the image sizes are not consistent and I want to limit the image sizes, resize them, to a nice thumbnail.</p> <p>How would I modify the XSLT to accomplish that?</p> <p>XML Sample:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;rss version ="2.0" xmlns:g="http://base.google.com/ns/1.0"&gt; &lt;channel&gt; &lt;title&gt;Company Name&lt;/title&gt; &lt;description&gt;Company description&lt;/description&gt; &lt;link&gt;http://www.mycompanyurl.com&lt;/link&gt; &lt;item&gt; &lt;title&gt;News Item Title&lt;/title&gt; &lt;link&gt;http://www.whateverurl.com/&lt;/link&gt; &lt;category&gt;Space&lt;/category&gt; &lt;pubDate&gt;12 April 1961&lt;/pubDate&gt; &lt;description&gt;Software to reduce your job search to a half hour per day. all major job sites, job boards, classifieds. unemployment paperwork, CRM, interviews, more&lt;/description&gt; &lt;image&gt; &lt;url&gt;~/App_Data/NewsControl/whatever.png&lt;/url&gt; &lt;title&gt;Whatever1&lt;/title&gt; &lt;link&gt;javascript:void(0)&lt;/link&gt; &lt;/image&gt; &lt;g:id&gt;1&lt;/g:id&gt; &lt;g:brand&gt;Whatever2&lt;/g:brand&gt; &lt;g:condition&gt;whatever3&lt;/g:condition&gt; &lt;g:price&gt;$whatever4&lt;/g:price&gt; &lt;g:product_type&gt;Whatever5&lt;/g:product_type&gt; &lt;/item&gt; &lt;/channel&gt; &lt;/rss&gt; </code></pre> <p>Here is the associated XSLT:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:template match="/"&gt; &lt;items&gt; &lt;xsl:for-each select="//item"&gt; &lt;item Name="{position()}" HeaderText="{title}" Text="{description}" NavigateUrl="{position()}" Date="{pubDate}" ImageUrl="{image/url}"/&gt; &lt;/xsl:for-each&gt; &lt;/items&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>Results of First Answer</strong>:</p> <pre><code>&lt;items&gt; &lt;xsl:for-each select="//item"&gt; &lt;item Name="{position()}" HeaderText="{title}" Text="{description}" NavigateUrl="{position()}" Date="{pubDate}" ImageUrl="/Tools/thumber.php?img={image/url}"/&gt; &lt;/xsl:for-each&gt; &lt;/items&gt; </code></pre> <p>I made these changes, enabled PHP on the server (testing on from the server and locally), and saw 2 issues: 1. I get no image, merely a no image box.</p> <ol> <li>If I try to edit the ImageUrl and tack on a "&amp;W=xxx&amp;H=xxx", the Visual Studio validator complains and throws up errors on the &amp;.</li> </ol> <p><strong>Update 2</strong> Here is the latest line in the XSLT: http://myserver.com/Tools/thumber.php?img=',image/url)}"/></p> <p>The corresponding image section in the XML</p> <pre><code>&lt;image&gt; &lt;url&gt;/Products/Jobfish/Images/Boxshots/Jobfish_DVDCaseCD_ShadowOut.jpg&lt;/url&gt; &lt;title&gt;Jobfish&lt;/title&gt; &lt;link&gt;javascript:void(0)&lt;/link&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload