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

Forums / Developing with Sitefinity / resolving image URLs in newsItem.Content

resolving image URLs in newsItem.Content

7 posts, 0 answered
  1. Scott Rozman
    Scott Rozman avatar
    93 posts
    Registered:
    10 Oct 2012
    04 Mar 2010
    Link to this post
    I am using the newsItem.Content method to pull information contained in a custom RSS feed, but have run into a problem with images that are referenced in the content.
    The URLs for the images are only the references to the images in the library, not a usable URL.
    i.e.
    [Libraries]2c3784c4-c22c-4dde-af4b-20732c0d52c6
    Is there a way that I can pull back the newsItem Content with the URLs resolved or some kind of function that that I can run on this string to replace the guid references?

    thanks in advance,
    Scott
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    04 Mar 2010
    Link to this post
    Hello Scott Rozman,

    Please take a look at this blog post - Resolving the url of dynamic links.

    Sincerely yours,
    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.
  3. Richard
    Richard avatar
    77 posts
    Registered:
    24 Oct 2007
    21 Apr 2010
    Link to this post
    Hi,
    I've read through the blog but am having issues resolving news item .content

    The content is something like the following:
    Latest news, please click <a href="[Sitefinity]b8b9a895-eedf-4f78-8eee-e2a771929249">right here!</a> Alternatively read our latest on the flight issues by clicking > Alternatively read our latest on the flight issues by clicking <a href="[Sitefinity]2342342-eedf-4f78-8eee-e2a771929249">right here!</a>

    Do I have to progmatically analyse the the content for "[" xx "]" and parse each one individually?
    Thanks
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Apr 2010
    Link to this post
    Hello Richard,

    You could use

    string content = (string)contentItem.GetMetaData("SomeData");
               if (!String.IsNullOrEmpty(content ))
               {
                   content = LinkParser.ResolveLinks(content , ContentManager.ResolveItemUrl);
                   
               }


    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.
  5. Richard
    Richard avatar
    77 posts
    Registered:
    24 Oct 2007
    21 Apr 2010
    Link to this post
    Thank you for the information, but ResolveItemUrl expects (ByVal provider As String, ByVal id As System.Guid, ByVal resolveAsAbsoluteUrl As Boolean).  It is a member of Telerik.Cms.Engine.ContentManager just in case I using the wrong one?  (FYI, I am using VB!)

    litContent.Text = Telerik.Cms.Web.LinkParser.ResolveLinks(item.Content, ContentManager.ResolveItemUrl)
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Apr 2010
    Link to this post
    Hi Richard,

    There are 7 overloads

    • ResolveLinks(string html)
    • ResolveLinks(string html, bool resolveAsAbsoluteUrl)
    • ResolveLinks(string html, bool preserveOriginalValue, bool resolveAsAbsoluteUrl)
    • ResolveLinks(string html, GetItemUrl itemUrl)
    • ResolveLinks(string html, ResolveUrl resolveUrl)
    • ResolveLinks(string html, GetItemUrl itemUrl, ResolveUrl resolveUrl, bool preserveOriginalValue)
    • ResolveLinks(string html, GetItemUrl itemUrl, ResolveUrl resolveUrl, bool preserveOriginalValue, bool resolveAsAbsoluteUrl)
     You can use AddressOf Operator , because ContentManager.ResolveItemUrl is considered as function delegate.

    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.
  7. Richard
    Richard avatar
    77 posts
    Registered:
    24 Oct 2007
    22 Apr 2010
    Link to this post
    Thank you! It works very well now. I had to use the AddressOf.

    litContent.Text = Telerik.Cms.Web.LinkParser.ResolveLinks(item.Content, AddressOf ContentManager.ResolveItemUrl)
Register for webinar
7 posts, 0 answered