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

Forums / Developing with Sitefinity / Custom ImageEditorDialog.ascx

Custom ImageEditorDialog.ascx

3 posts, 1 answered
  1. DPC David
    DPC David avatar
    26 posts
    Registered:
    28 Dec 2009
    26 Jul 2010
    Link to this post
    Hi

    while working on my custom ImageEditorDialog i found this Blog post Extend RadEditor dialogs to add captions for images. Now i have the following problem: If i have pressed the insert button, the path of the selected image ends with an querystring http://localhost:54153/.......sflb.ashx?width=300&height=300&decreaseOnly=true which i didn't want to be added. So i found in the native java script function insertLink() the following code :
            if (selValue.value.indexOf("~/") == 0) {
                closeArgument.setAttribute("sfref", selValue.value);
            } else if (selectedItem != undefined && selectedItem.unresolved) {
                closeArgument.setAttribute("sfref", selectedItem.unresolved);
            } else if (uplImg != undefined && uplImg.attributes["sfref"] != undefined) {
                closeArgument.setAttribute("sfref", uplImg.attributes["sfref"].value);
                closeArgument.src = uplImg.src;
            } else {
                closeArgument.removeAttribute("sfref");
            }
    which is responsible for the behavior but i don't know how to change the line so that the path is still set with image caption (without query string) instead with image id.

    Regards David
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    27 Jul 2010
    Link to this post
    Hi DPC David,

    Changing the appended QueryString requires reflection and solution will work in full trust only. The problem is that this QueryString is hardcoded and cannot be changed easily due to the privacy of LibraryImageDialogContainer. The QueryString is not added by the js code, it is added from ImageEditorDialog and then js code just gets the image url.

    sample

    public class CustomImageEditorDialog : Telerik.Libraries.WebControls.ImageEditorDialog
       {
           public CustomImageEditorDialog()
           {
     
           }
     
           protected override void CreateChildControls()
           {
               base.CreateChildControls();
     
               Guid itemID = (Guid)ReflectionHelper.GetPrivateField(this, typeof(ImageEditorDialog), "itemID");
               if (itemID != Guid.Empty)
               {
                   LibraryManager Manager = new LibraryManager();
                   IContent content = Manager.GetContent(itemID);
                   string name = (string)content.GetMetaData("Name");
     
                   GenericContainer<ImageEditorDialog> container = (GenericContainer<ImageEditorDialog>)ReflectionHelper.GetPrivateField(this, typeof(ImageEditorDialog), "container");
                   if (container != null)
                   {
                       Image uploadedImage = container.GetControl<Image>("uploadedImage", false);
                       if (uploadedImage != null)
                       {
                           uploadedImage.ImageUrl = content.UrlWithExtension + "?width=200&height=200&decreaseOnly=true";
                           uploadedImage.Attributes.Add(LinkParser.InternalLinkAttrebuteName, String.Concat("[", content.ProviderName, "]", content.ID));
                       }
                   }
               }
           }
     
       }

    The second option would be to alter closeArgument.src = uplImg.src; in the js code insertLink()

    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
    Answered
  3. DPC David
    DPC David avatar
    26 posts
    Registered:
    28 Dec 2009
    27 Jul 2010
    Link to this post
    Hi

    thanks for the hint. I choosed the second solution and used substring and indexOf. Now it works fine for me

    closeArgument.src = uplImg.src.substring(0, uplImg.src.indexOf('?'));

    Regards David
Register for webinar
3 posts, 1 answered