+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / News thumbnail

News thumbnail

6 posts, 0 answered
  1. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    28 May 2010
    Link to this post
    Hi,
    I am using News module in sitefinity. In that module I want to display some default thumbnail image if thumbnail is not uploaded for any particular news. Is this possible??

    -Thanx
    Shraddha.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    28 May 2010
    Link to this post
    Hello shraddha,

    Could you specify for which version you want to do this - Sitefinity 3.x or Sitefinity 4.x?

    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    28 May 2010
    Link to this post
    Hi,
    Thanx for the reply.
    I am using sitefinity 3.7 SP3 version.

    --Thanx
    Shraddha
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    28 May 2010
    Link to this post
    Hi shraddha,

    Please posts you questions in the thread for Sitefinity 3.x. Thus we will be able to provide you with a proper answer. You can do this easily. Create a custom control that inherits from NewsView. Override SetItemMetadata. Get the content item metadata for Thumbnail. If the value is null or string empty set a default image to the control with ID="Thumbnail". You can get the control from the itemContainer which is a parameter of SetItemMetadata method

    sample code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.News.WebControls;
    using System.Web.UI.WebControls;
    using System.Web.UI;
    using Telerik.Cms.Engine;
    using Telerik.Cms.Web;
    using Telerik.Cms.Web.UI;
    using Telerik.Cms.Engine.ContentViewFiltering;
     
    /// <summary>
    /// Summary description for NewsViewCustomControl
    /// </summary>
    public class NewsViewCustomControl : NewsView
    {
     
        public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx";
            }
     
        }
     
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx";
            }
     
        }
     
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
     
        public override Type AssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
     
     
     
        protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
        {
           // base.SetItemMetadata(itemContainer, contentItem);
            var someControl = itemContainer.FindControl("Litral1") as Literal;
     
            var thumbMetakey = (string)contentItem.GetMetaData("Thumbnail");
            if (String.IsNullOrEmpty(thumbMetakey))
            {
                //set default image
            }
        }
    }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. shraddha
    shraddha avatar
    87 posts
    Registered:
    18 May 2009
    29 May 2010
    Link to this post
    Hi,
    thanx for the reply.
    I will take care from the next time and add the thread in appropriate version.
    I did the same thing which you have suggested. But how do I assign the default image.
    If I am writing like

    if (String.IsNullOrEmpty(thumbMetakey))
            {
                contentItem.SetMetaData("Thumbnail", "/Images/news.gif");
            }

    but it is not showing the image.

    --Thanx
    Shraddha

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    30 May 2010
    Link to this post
    Hello shraddha,

    Check whether the metakey is empty. If it is empty set the ImageUrl of your control to some default image

    var thumbMetakey = (string)contentItem.GetMetaData("Thumbnail");
    if (String.IsNullOrEmpty(thumbMetakey))
    {
        imgControl.ImageUrl = "/Libraries/DefaultResources/Image.sflb.ashx"
    }


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
6 posts, 0 answered