More in this section

Forums / Developing with Sitefinity / Thumbnail image tootltip in news

Thumbnail image tootltip in news

6 posts, 0 answered
  1. Mohudoom Faluludeen
    Mohudoom Faluludeen avatar
    19 posts
    Registered:
    06 Nov 2009
    11 Jun 2010
    Link to this post
    Hi,

    I just want to show tooltip / alt tag for the thumnail image added through news module. Can you please guide me how to do this?

    Thanks


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Jun 2010
    Link to this post
    Hi Mohudoom Faluludeen,

    To set the tooltip you have to

    1. Create an additional Metakey for News provider - say ToolTipText. This will allow you to set the ToolTip instead of generating it randomly to the image

    To add additional metakeys Please take a look at our UserManual section Adding Custom fields, page 214


    2. Create a custom control that inherits from NewsView, override SetItemMetadata method, get the image control by ID from the container - use itemContainer.FindControl("Tumbnail")

    3. Then set the ToolTip property to the image object. You can use contentItem parameter of SetItemMetadata to get the ToolTipText - contentItem.GetMetaData("ToolTipText");

    Kind 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. Mohudoom Faluludeen
    Mohudoom Faluludeen avatar
    19 posts
    Registered:
    06 Nov 2009
    11 Jun 2010
    Link to this post
    Hi,

    Thanks for the quick reply. I knew additional meta key for tool tip will work. But i want to know can i get the alt tag added for the image while uploading and show it on the news page? Is there any way i can do this?


    Thanks
    Faluludeen
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    11 Jun 2010
    Link to this post
    Hi Mohudoom Faluludeen,

    If the image has been uploaded to Images and Documents module you can use the Alt tag that has been set for this image. You have to access the "Tumbnail" metadata inside SetItemMetadata  as described in the previous post. The value will return [Provider]GUID value. So, the GUID here is the ID of the Image. You can create an instance of LibraryManager and get the IContent item. Then get "AlternateText" metadata for this IContent item and pass it to the ToolTip of the Image.

    All the best,
    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. Mohudoom Faluludeen
    Mohudoom Faluludeen avatar
    19 posts
    Registered:
    06 Nov 2009
    14 Jun 2010
    Link to this post
    Hi,

    To get Tumbnail meta data, should i create any custom control? can you please give me sample custom control which inherits news view and the steps to do that?

    Thanks
    Faluludeen
  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    14 Jun 2010
    Link to this post
    Hello Mohudoom Faluludeen,

    Here is a sample code on this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.News.WebControls;
     
    /// <summary>
    /// Summary description for CustomNewsView
    /// </summary>
    public class CustomNewsView : NewsView
    {
        public CustomNewsView()
        {
     
        }
        protected override void SetItemMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
        {
            base.SetItemMetadata(itemContainer, contentItem);
            // do the finding here, then initalize the LibraryManager
        }
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return typeof(NewsView);
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
        public override Type AssemblyInfo
        {
            get
            {
                return typeof(NewsView);
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }
         
    }

    Once again, you should do get the tooltip in the SetItemMetaData code. Here is some additional information on working with the LibraryManager class - http://www.sitefinity.com/help/developer-manual/libraries-files-managing.html

    Kind regards,
    Georgi
    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