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

Forums / Developing with Sitefinity / Get Image At Custom Size

Get Image At Custom Size

2 posts, 0 answered
  1. Raymond Dowe
    Raymond Dowe avatar
    37 posts
    Registered:
    10 Mar 2010
    11 Jan 2013
    Link to this post

    I'm using the following code inside a repeater to get an image that has been selected in a custom module.

               

               

    public partial class Controls_MeetTheTeam : System.Web.UI.UserControl
    {
     
        private LibrariesManager libMng;
     
     
        protected void Page_Load(object sender, EventArgs e)
        {
            libMng = LibrariesManager.GetManager();
            var providerName = String.Empty;
            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);
            Type employeeType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Employees.Employee");
            var employees = dynamicModuleManager.GetDataItems(employeeType).Where(i => i.Status == ContentLifecycleStatus.Live);
            rpt_employees.DataSource = employees;
            rpt_employees.DataBind();
        }
     
     
        protected void rpt_employees_OnItemDataBound(Object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var employee = e.Item.DataItem as DynamicContent;
                var link = employee.GetValue("Photo") as ContentLink[];
                var image = libMng.GetImage(link[0].ChildItemId);
                 
                Literal lit_name = (Literal)e.Item.FindControl("lit_name");
                Literal lit_bio = (Literal)e.Item.FindControl("lit_bio");
                Literal lit_title = (Literal)e.Item.FindControl("lit_title");
                HyperLink hl_email = (HyperLink)e.Item.FindControl("hl_email");
                Image img_thumb = (Image)e.Item.FindControl("img_thumb");
                Image img_full = (Image)e.Item.FindControl("img_full");
     
                lit_name.Text = employee.GetValue("Name").ToString();
                lit_title.Text = employee.GetValue("Title").ToString();
                lit_bio.Text = employee.GetValue("Bio").ToString();
                hl_email.Text = employee.GetValue("Email").ToString();
                hl_email.NavigateUrl = "mailto:" + employee.GetValue("Email").ToString();
                img_thumb.ImageUrl = image.Url;
                img_thumb.AlternateText = employee.GetValue("Name").ToString();
                img_full.ImageUrl = image.Url;
                img_full.AlternateText = employee.GetValue("Name").ToString();
            }
        }
    }


    Is it possible to get the "Photo" image at a different size programmatically? I remember in the old days I used to be able to do this by adding query string parameters to the url, but AFAIK that doesn't work any more.

  2. Raymond Dowe
    Raymond Dowe avatar
    37 posts
    Registered:
    10 Mar 2010
2 posts, 0 answered