Copied to clipboard

Flag this post as spam?

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


  • Sébastien Richer 194 posts 429 karma points
    Sep 18, 2012 @ 20:46
    Sébastien Richer
    0

    Using pinterest embed - Saving node - Image url is changed

    Hello,

    I'm trying to paste in an embed code from Pinterest in a content element, through an RTE, in my CMS. I click on "html" on the RTE, paste in my code, update. Then I see the Pinterest embed correctly displayed. Then I save. once I save it doesn't work anymore my image SRC was changed. It was http://whatver.com/[...].jpg, now it's /whatever.com/[...].jpg. Which makes little or no sense.

    What is doing this (umbraco saving it seams?) and how can I go around this?

    I can't really not support this...

    Thanks!

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Sep 19, 2012 @ 19:37
    Jan Skovgaard
    0

    Hi Sébastian

    What version of Umbraco are you using? If it's not 4.9 then you should open up the umbracoSettings.config file (found in the config folder) and set this line from

            <TidyEditorContent>True</TidyEditorContent>

    to

            <TidyEditorContent>False</TidyEditorContent>

    It's previously not been a best practice to do so, since this opens up for a lot of bad and outdated markup to be rendered as the output if for some reason someone think it's still cool to use <font> tags etc. :) - But with the new HTML5 elements and a growing need to be able to embed stuff like youtube videos, pinterest stuff etc. it does not neccesarily make sense to have tidy clean the code before it's being rendered.

    If you howver would like to still have tidy enabled you can create macro based on the multi text option, and make sure the macro can be used in the rich text editor and then you can paste your pinterest code in to the macro and render the rich text output.

    Hope this helps!

    /Jan

  • Sébastien Richer 194 posts 429 karma points
    Oct 01, 2012 @ 23:56
    Sébastien Richer
    0

    Hi Jan,

    Finally got around to work on this issue some more, I tried to change the setting you mentionned but it did not work. I get the same behavior.

    I reset IIS after changing the setting to make sure it was re-loaded, but no change. I'm running on Umbraco 4.7.2.

    I tried a quick and dirty macro to do this:

    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    @{
        var code = "";
        if (!string.IsNullOrEmpty(GetParameter("Code")))
        {
            code = GetParameter("Code");
        }
    }
    
    @code

    Which would basically allow any HTML, but the rendered HTML still got reformated, notably, the image src changed and a slew of other problems showed up, I'm already printing my RTE through a razor macro. So then, that's like a macro in a macro and just like that I don't think it's supported.

    Here is the pinterest code as a reference.

    <div style='padding-bottom: 2px; line-height: 0px'><a href='http://pinterest.com/pin/47147127319334841/' target='_blank'><img src='http://media-cache0.pinterest.com/upload/47147127319334841_lTDUgSz4_c.jpg' border='0' width='600' height ='337'/></a></div><div style='float: left; padding-top: 0px; padding-bottom: 0px;'><p style='font-size: 10px; color: #76838b;'>Source: <a style='text-decoration: underline; font-size: 10px; color: #76838b;' href='http://westeastsouthnorth.tumblr.com/post/21098011997/tuvalu'>westeastsouthnorth.tumblr.com</a> via <a style='text-decoration: underline; font-size: 10px; color: #76838b;' href='http://pinterest.com/kasandracook/' target='_blank'>Kasandra</a> on <a style='text-decoration: underline; color: #76838b;' href='http://pinterest.com' target='_blank'>Pinterest</a></p></div>

    I guess I should hook into the Umbraco source and go through with debug to find out really what is applying that change...

    Thanks for the help, should the TidyEditorContent be doing the trick for me?

  • Sébastien Richer 194 posts 429 karma points
    Oct 19, 2012 @ 21:35
    Sébastien Richer
    0

    Ok so I'm still swinging at this issue. Here's my setup. My document type has an RTE field. I display it through this template and macro:

    @using MyNamespace.Common
    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
    
    <div id="websiteContentContainer">
        <h1 class="section-title">@Model.titre</h1>
        <div class="website-text">@Model.texte</div>
    </div> 
    <%@ Master Language="C#" MasterPageFile="~/masterpages/Master.master" AutoEventWireup="true" %>
    
    <asp:Content ContentPlaceHolderID="MasterContent" runat="server">
        <umbraco:Macro ID="Macro3" Alias="WebPage" runat="server" />
    </asp:Content>

    But the problem actually occurs right away on the back office side (then also in front end). When I insert the pinterest code in the RTE I see the image correctly, just saving that node then will cause the bug.

    Honestly, I'm surprised no one else has had this issue? There must something I'm missing and or doing wrong...

    I'll try some more stuff next week and post this to twitter to get more guns on the issue.

    EDIT: Ok editing posts completely destroys them lol...

    Thanks!

  • Sébastien Richer 194 posts 429 karma points
    Oct 23, 2012 @ 17:54
    Sébastien Richer
    0

    I have found in "tinyMCEImageHelper.cs", the method "private static string StripSrc(string cleanTag, Hashtable ht)" at line #121 is the "culprit.

    private static string StripSrc(string cleanTag, Hashtable ht)
            {
                string src = helper.FindAttribute(ht, "src");
                //get the media folder, minus the starting '~'
                string mediaRoot = Umbraco.Core.IO.SystemDirectories.Media.Replace("~", string.Empty);
    
                // update orgSrc to remove umbraco reference
                int mediaRootIndex = src.IndexOf(mediaRoot);
                if (mediaRootIndex > -1)
    
                    src = src.Substring(mediaRootIndex, src.Length - mediaRootIndex);
    
                cleanTag += " src=\"" + src + "\"";
                return cleanTag;
            }

    Following the yellow brick road leads me to this function, so the solution might be anywhere along the way.

     

     

  • Sébastien Richer 194 posts 429 karma points
    Oct 24, 2012 @ 17:42
    Sébastien Richer
    1

    So! I founda workaround, just adding

    rel='popo'

    to the img tag of the pinterest embed code, avoids that src manipulation.

    It's really just a workaround and not a solution though, but the long term fix would require code change in Umbraco source.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies