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

Forums / Developing with Sitefinity / Image Library Bug?

Image Library Bug?

5 posts, 1 answered
  1. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    02 Jul 2009
    Link to this post

    I have created a generic content rotator, a very simple control that i have display a bunch of content.
    I found that there is a strange bug however.
    When i create the content and insert an image from the image library it does not show on my control, it displays a broken link image.

    Now to fix that i can go into the html code of the generic content and delete this part out of the html : sfref="[Libraries]92e2a20b-2b42-4b46-8f29-3ec46a520bbf".

    If I do that it works perfect. However it’s not something my end users will be able to do. They only want to drag in the image.

    Is his a bug? What can be done about this?

  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    02 Jul 2009
    Link to this post
    Hello Andrew,

    The attribute sfref (sfref="[Libraries]92e2a20b-2b42-4b46-8f29-3ec46a520bbf")
    is used for the dynamic links in Sitefinity. If you are using you own control to display dynamic links you need to add a functionality to resolve the links:1. Add this method in your control:
            public string GetItemUrl(string provider, Guid id, bool resolveAsAbsoluteUrl) 
            { 
                if (ContentManager.Providers.ContainsKey(provider)) 
                { 
                    IContent cnt = ContentManager.Providers[provider].GetContent(id); 
                    if (cnt != null
                        return VirtualPathUtility.ToAbsolute(cnt.UrlWithExtension, this.Context.Request.ApplicationPath); 
                } 
                else 
                { 
                    string url = CmsHelper.GetPageUrl(id ); 
                    if (!string.IsNullOrEmpty(url)) 
                    { 
                        return url; 
                    } 
                } 
                return String.Concat("Item not found: [", provider, "]", id); 
            } 

    2. I suppose you have used RadEditor to generate the html content. You need to modify the html with this function:
    //textWithDynamicLinks is the html containing the sfref attribute 
    string resolvedLinksHtml= LinkParser.ResolveLinks(textWithDynamicLinks, this.GetItemUrl, nullfalsefalse); 
    //resolvedLinksHtml does not contain sfref attribute and links will be working 

    I hope this helps you.

    Sincerely yours,
    Parvan
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
  3. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    03 Jul 2009
    Link to this post
    Thanks for that.
    Trying to use the code. But small problem.
    I looked up CmsHelper, and i thought it was in the telerik.cms.web namespace.
    But using that namespace i get 'does not contain definition for GetPageUrl'

    Is that the right namespace?
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    03 Jul 2009
    Link to this post
    Hello Andrew,

    You are right. The code we sent in our previous reply will work in SP3. Here is something that will work with the previous versions:
    public string GetItemUrl(string provider, Guid id, bool resolveAsAbsoluteUrl) 
            { 
                if (ContentManager.Providers.ContainsKey(provider)) 
                { 
                    IContent cnt = ContentManager.Providers[provider].GetContent(id); 
                    if (cnt != null
                        return VirtualPathUtility.ToAbsolute(cnt.UrlWithExtension, this.Context.Request.ApplicationPath); 
                } 
                else 
                { 
                    // we assume it is a page 
                    SiteMapNode node = SiteMap.Provider.FindSiteMapNodeFromKey(id.ToString()); 
                    if (node != null
                        return this.ResolveClientUrl(node.Url); 
                } 
                return String.Concat("Item not found: [", provider, "]", id); 
            } 

    All the best,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Answered
  5. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    03 Jul 2009
    Link to this post
    Thanks, that fixed it.
Register for webinar
5 posts, 1 answered