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

Forums / Developing with Sitefinity / Need relative NOT absolute paths for custom field that selects images to associate with blog/event/news posts

Need relative NOT absolute paths for custom field that selects images to associate with blog/event/news posts

3 posts, 0 answered
  1. Richard
    Richard avatar
    64 posts
    Registered:
    09 Oct 2012
    13 Aug 2013
    Link to this post
    I'm not sure where I found the steps that described a very simple way to allow my users to select/upload an image to associate with their blog/news/event posts, but it gave these steps.

    1. Add new custom field for blogs
    2. Set its type to short text
    3. Set "Interface widget for entering data" to Custom
    4. In the custom textbox enter:  Telerik.Sitefinity.Web.UI.Fields.ImageField
    5. Save the custom field and test it in blog post item.

    The problem I'm having is that apparently the URL that is created for that image is absolute. I need it to be a relative. Does anyone know where/if/how I can change it to be a relative path?
  2. Saad
    Saad avatar
    98 posts
    Registered:
    10 Oct 2008
    07 May 2014 in reply to Richard
    Link to this post

    You could simply do something like this:

    var i = this.get_ImageSelector();
    var imgUrl = (i.get_value() + '').toLowerCase();
    imgUrl = imgUrl.substring(imgUrl.indexOf('/images'), imgUrl.length);

     You would need to be careful when site is hosted in virtual directory.

  3. Keith
    Keith avatar
    2 posts
    Registered:
    30 Nov 2009
    18 Jul 2014 in reply to Saad
    Link to this post

    Did you ever get this issue resolved?  I'm running into the exact same issue now and any pointers you have would be appreciated.

     

3 posts, 0 answered