Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sajid Riaz 142 posts 165 karma points
    Aug 26, 2010 @ 11:13
    Sajid Riaz
    0

    Umbraco 4.5: thumbnail for news list

    hi everyone,

     

    I have a news item with 3 properties :

    summary field as textstring multiple

    Summary  Image as media picker.

    bodyText as richtexteditor

    So the user creates a news item adds a summary and uploads the summary image and populates the news using the rich text editor.

    I have a list of all the news items user has created on the right handside of the page.

    I want to be able to show a thumbnail image of the image the user uploads to the summary image property in a list of all news items.

    whats the best way of doing this.  I'm sure I've read somewhere that theres a thumbnail of the image available but I'm not sure how to retreive it.

    The alternate way I suppose would be to get the summary image and resixe it using ImageGen.  But I would like to know how to do it using the thumbnail property.

    >>sajid 

     

     

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Aug 26, 2010 @ 13:31
    Thomas Höhler
    1

    As I know the upload field scans if the uploaded file is an image and then gegerates an thumbnail from it with "_thumb" inserted before the file extension. eg: I have uploaded a pic named test.jpg then I have in the same folder a file named test_thumb.jpg.

    To get the url of the thumb you can use the replace function of the umbraco.library, like this:

    Snippet

    umbraco.library.Replace(data [@alias = 'YourUploadFieldAlias'], '.jpg', '_thumb.jpg')

     

    or in the new schema

    umbraco.library.Replace(./YourUploadFieldAlias, '.jpg', '_thumb.jpg')

    hth, Thomas

  • Sajid Riaz 142 posts 165 karma points
    Aug 27, 2010 @ 19:37
    Sajid Riaz
    0

    Thomas, thank you for you solution above.

    This is my XSLT for anyone else:

     <img>
       <xsl:attribute name="src">
         <xsl:value-of select="umbraco.library:Replace(umbraco.library:GetMedia(./newsImage, 0)/umbracoFile, '.jpg', '_thumb.jpg')" /></xsl:attribute>
     </img>
         

Please Sign in or register to post replies

Write your reply to:

Draft