Search code examples
sitecoreglass-mapper

Get image item name


I'm getting a Image from sitecore with glass

    [SitecoreField(FieldName = "Icon Image")]
    public virtual Image IconImage { get; set; }

Now I need to get my image's item name. Is there any way of doing this without making another call to the db?


Solution

  • Get the item name from the image source as the name in the path is always the item name:

    Path.GetFileNameWithoutExtension(IconImage.Src)