Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pixelpushr 12 posts 34 karma points
    Mar 10, 2014 @ 10:19
    Pixelpushr
    0

    Tiny MCE not giving full URL

    I need the editor to give me the full path to images etc from the editor which it currently doesnt do.

    Ive tried setting "relativeurls", "removescripthost" and "converturls" all to 0 in tinymce.js and tinymcesrc.js (in umbracoclient\tinymce3) which seems to do absolutely nothing.

    Has anyone had this issue before?

    Thanks

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 10, 2014 @ 12:05
    Jeroen Breuer
    0

    In the Hybrid Framework I have a method for this:

    /// <summary>
    /// Add an absolute path to all the img tags in the html of an e-mail.
    /// </summary>
    /// <param name="html"></param>
    /// <returns></returns>
    private static string AddImgAbsolutePath(string html)
    {
        HtmlDocument doc = new HtmlDocument();
        doc.LoadHtml(html);
    
        var uri = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);
        var domainUrl = string.Format("{0}://{1}", uri.Scheme, uri.Authority);
    
        if (doc.DocumentNode.SelectNodes("//img[@src]") != null)
        {
            foreach (HtmlNode img in doc.DocumentNode.SelectNodes("//img[@src]"))
            {
                HtmlAttribute att = img.Attributes["src"];
                if (att.Value.StartsWith("/"))
                {
                    att.Value = domainUrl + att.Value;
                }
            }
        }
    
        return doc.DocumentNode.InnerHtml;
    }

    If you use that all media will have full url's.

    Jeroen

  • Pixelpushr 12 posts 34 karma points
    Mar 10, 2014 @ 12:10
    Pixelpushr
    0

    That package seems to suggest its compatible with v6.1 this site im working on is an older v4.7.1 site which I forgot to inclide!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 10, 2014 @ 12:12
    Jeroen Breuer
    0

    The Hybrid Framework is not a package, but a complete website. Just paste that code in your own project and use it each time you want to have full url's for media.

    Jeroen

  • Pixelpushr 12 posts 34 karma points
    Mar 10, 2014 @ 14:05
    Pixelpushr
    0

    Where abouts would this go?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 10, 2014 @ 14:11
    Jeroen Breuer
    0

    Do you have a project with some custom code? You could place it in there or in the App_Code folder. Than when you want to render the HTML of the RTE first let it go through that method. Something like this in Razor:

    @Html.Raw(AddImgAbsolutePath(Model.Content.GetpropertyValue<string>("bodyText")))

    Jeroen

  • Pixelpushr 12 posts 34 karma points
    Mar 11, 2014 @ 12:07
    Pixelpushr
    0

    Thanks I'll look at that

    Although there must be a simpler way though surely, via some form of method I was trying previously? I've seen so many posts of various forums saying that method ususually works?

Please Sign in or register to post replies

Write your reply to:

Draft