More in this section
Forums / Developing with Sitefinity / Get image by front end url

Get image by front end url

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Scott
    Scott avatar
    5 posts
    11 Aug 2014
    04 Apr 2017
    Link to this post

    I am trying to get an image based on the rendered "src" tag  of an image in a blog.  I was able to get it work, wondering if there is a better to accomplish it without the loop and splitting the "src" path.


    string[] pathArray = path.Split('/');
                   string albumName = pathArray[pathArray.Length -2];
                   string itemName = pathArray[pathArray.Length - 1].Substring(0, pathArray[pathArray.Length - 1].IndexOf('.'));
                   var domain = HttpContext.Current.Request.Url.ToString().Replace(HttpContext.Current.Request.Url.AbsolutePath.ToString(), "").Trim();
                   var imageVersions = App.WorkWith().Albums().Where(a => a.Title.Equals(albumName)).Get().FirstOrDefault().Images().Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live &&  i.UrlName.Equals(itemName));
                   foreach (Telerik.Sitefinity.Libraries.Model.Image image in imageVersions)
                       var imageUrl = image.ResolveMediaUrl(false).Replace(domain, " ");
                       if (imageUrl == path)
                           return image;
               return null;




1 posts, 0 answered