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

Forums / Developing with Sitefinity / Photo Captions in Galleries

Photo Captions in Galleries

2 posts, 0 answered
  1. Chris
    Chris avatar
    1 posts
    Registered:
    20 Oct 2010
    20 Oct 2010
    Link to this post
    I am installing photo galleries and would like the thumbnail caption to be different from the enlarged photo that appears in the lightbox effect. Is it possible to have one caption for the thumbnail and another for the full-sized photo?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Oct 2010
    Link to this post
    Hi Chris,


    You have to create a custom class that inherits from ImageGallery and override SetItemMetadata where you have access to the content item and DownloadLink. Then you can add Attributes to the download link

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Libraries.WebControls;
    using System.Web.UI.WebControls;
      
    /// <summary>
    /// Summary description for ImageGalleryCustom
    /// </summary>
    public class ImageGalleryCustom : ImageGallery
    {
        public ImageGalleryCustom()
        {
        }
      
        public override string ItemListTemplatePath
        {
            get
            {
               // here you have to return your custom template
                return "~/Sitefinity/Admin/ControlTemplates/Libraries/Modes/GallerySimpleList.ascx";
            }
      
        }
      
        protected override void SetListMetadata(System.Web.UI.Control itemContainer, Telerik.Cms.Engine.IContent contentItem)
        {
            base.SetListMetadata(itemContainer, contentItem);
      
            switch(galleryViewMode)
            {
                case GalleryViewMode.Lightbox:
                case GalleryViewMode.BigImageAndList:
                case GalleryViewMode.ListDetails:
                    HyperLink downloadLink = itemContainer.FindControl("DownloadLink") as HyperLink;
                    downloadLink.Attributes.Add("caption", contentItem.GetMetaData("Name").ToString());
      
      
                 .....
                       ....
             }
    }


    You can expose the attribute key as a public property so you can change it later from your control designer.

    By default we do not set the caption attribut  in the img tab of the thumbnail and the LightBox uses the title, but most probably your requirement will need changing the Lightbox script library as well.


    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
2 posts, 0 answered