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

Forums / Developing with Sitefinity / How to Retrieving Image from Rich Textbox Editor in Dynamic Modules Using the Module Builder API

How to Retrieving Image from Rich Textbox Editor in Dynamic Modules Using the Module Builder API

7 posts, 0 answered
  1. Ajay
    Ajay avatar
    46 posts
    Registered:
    14 Nov 2013
    16 Jun 2014
    Link to this post

    Hi All,

    I'm Using Dynamic Modules Using the Module Builder API, I added images in Rich text box Editor ,

    I'm Unable to Get Image url's in my web site.

    i'm getting image tag like

    <img src="[libraryprovider2][16 digit GUID]"/>

    I wrote code like 

    var allentries = Extensions.RetrieveCollectionOfModuleData();
    var firstRow = allentries.First(x => x.GetValue<string>("uname") == "Ajay");
    divdescription.InnerHTML = firstRow.GetValue("description").ToString();

    Please help me, how to Get images from Rich Text box Editor.

     Thanks

    Ajay

  2. Ivan D. Dimitrov
    Ivan D. Dimitrov avatar
    310 posts
    Registered:
    26 Mar 2015
    18 Jun 2014
    Link to this post
    Hi Ajay,

    Since you can get the GUID of the image stored in the Rich Text field, you can retrieve it using the Images API by using this guid. In general the Rich Text field returns a persisted value of type string that includes all of the markup present there. The markup consists of an img tag with its source equal to the url of your image, alt text and title equal to your image's metadata and a sfref attribute that is formed in the following way [mediatype|ProviderName]itemGuid. 

    The best way for you to proceed is to trim the markup string such that you can get the GUID or URL of the image and then use it as you please. Below you can find the code I used to get the value of my RichTextField:
    DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
                Type richTextType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.RichTextFieldTest.RichText");
     
                var richTextItem = dynamicModuleManager.GetDataItems(richTextType).ToList();
     
                foreach (var item in richTextItem)
                {
                      if (item.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master)
                    {
                        var HTMLField = item.GetValue("RichText");
                    }
        
                }


    Regards,
    Ivan D. Dimitrov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Ajay
    Ajay avatar
    46 posts
    Registered:
    14 Nov 2013
    23 Jun 2014 in reply to Ivan D. Dimitrov
    Link to this post

    Hi Ivan,

    Thanks for Reply , I'm Doing same as Above but I Did n't Get Image URL.

    here i'm adding sample video containing my code.

    I'm using version 6.2 and Using multisite management  

    Please Help me how to solve this.

     

    Thanks 

    Ajay

     

  4. Ivan D. Dimitrov
    Ivan D. Dimitrov avatar
    310 posts
    Registered:
    26 Mar 2015
    23 Jun 2014
    Link to this post
    Hi Ajay,

    Looks like you are almost there. The description value you get is the correct markup of the field, so you will need to cast it to string and trim the string such that only the Guid is present. From then on you can get the image by matching this Guid with the image's ID. I believe there is abundant information on trimming and substringing a string in c# available on the web.

    Regards,
    Ivan D. Dimitrov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  5. Ajay
    Ajay avatar
    46 posts
    Registered:
    14 Nov 2013
    24 Jun 2014
    Link to this post

    Hi Ivan,

    I'm Having Multiple Images with Content( different for Each Row ),

    How would i know start index,

    Please Help me and send me sample code containing Multiple Images and static text

    Thanks

    Ajay

  6. Ivan D. Dimitrov
    Ivan D. Dimitrov avatar
    310 posts
    Registered:
    26 Mar 2015
    24 Jun 2014
    Link to this post
    Hi Ajay,

    I am afraid I cannot do that as this case is very specific to your project.

    I can recommend you try and use an image field instead of inserting the images in the RichText editor. This will ease the process of you acquiring the desired images.

    You can see for your self the extensive amount of markup that the Editor generates and thus it makes filtering out the images in it difficult to get hold of.

    Regards,
    Ivan D. Dimitrov
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  7. Ajay
    Ajay avatar
    46 posts
    Registered:
    14 Nov 2013
    25 Jun 2014
    Link to this post

    Hi Ivan,

    Thanks for Replay, 

    Finally solved problem with this link

    Thanks

    Ajay

     

     

7 posts, 0 answered