ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Problem with YouTube Embeds in Weblog Entries

October 23, 2009 5:27am

Subscribe [11]
  • #1 / Oct 23, 2009 5:27am

    Giles Thurston

    34 posts

    Hi,

    I’m having a problem with embedding the YouTube player in a weblog entry.  I have the body field set to allow all HTML and when I paste the embed code in through the ExpressionEngine control panel all work’s fine.

    However when I am posting a weblog entry from an external source, such as MarsEdit or Feedgrab, the Youtube code gets changed from this:

    <object width="425" height="344"><param name="movie" 
    value="http://www.youtube.com/v/YiefzD2J1_U&hl=en&fs=1&"></param>
    </param></param><embed src="http://www.youtube.com/v/YiefzD2J1_U&hl=en&fs=1&" 
    type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" 
    width="425" height="344"></embed></object>

    to this:

    <object width=“425” height=“344”><param 
    name=“movie” 
    value=“http://www.youtube.com/v/YiefzD2J1_U&hl=en&fs=1&”></param><
    param name="allowFullScreen" value="true"></param></param><embed 
    src=“http://www.youtube.com/v/YiefzD2J1_U&hl=en&fs=1&” 
    type=“application/x-shockwave-flash” allowscriptaccess=“always” 
    allowfullscreen=“true” width=“425” 
    height=“344”></embed></object>

    It looks like the object and embed tags are being html encoded to prevent cross scripting hacks etc.  As I’ve already mentioned, the weblog field is set to allow “all html” and I’m at a loss as to how fix this. 

    Is there some mystical EE setting somewhere I’m missing?

    Any help would be greatly received 😊

  • #2 / Oct 23, 2009 11:04am

    Ingmar

    29245 posts

    Have you seen these entries in the wiki?

    They deal with the issue in a little more detail.

  • #3 / Oct 23, 2009 3:47pm

    Giles Thurston

    34 posts

    Yes read them both and pretty much every forum posting relating to Youtube.  None of them relate to my issue unfortunately :(

    The Wiki articles are fine if you are manually posting through the EE Control Panel.  However I don’t have that problem as I can easily add YouTube videos through the EE CP simply by pasting in the embed code that Youtube provides.

    My issue is when I push a post with a Youtube embed into EE from an external source, specifically MarsEdit on the Mac or by using FeedGrab to scrape posts out of my Tumbelog.  In both these instances the embed code appears to be encoded, presumably to prevent dangerous code being injected into EE.

    Where can I ask EE to not do this?  At the momentI’m having to login to the control panel and change posts that come from MarsEdit, which is frustrating and do the same with posts from Feedgrab, which is not practical as this is run automatically using a cron job

  • #4 / Oct 23, 2009 4:00pm

    Sue Crocker

    26054 posts

    Giles, there are some servers that do this when posting. It was a bug in PHP Version 5.2.8.

    I used the exp:replace plugin to convert the greater than and less than items back to > and <.

  • #5 / Oct 24, 2009 7:36pm

    Giles Thurston

    34 posts

    Thanks Sue, will check out the version of php my server is running.  Thanks for heads up on exp:replace plugin as well

    Cheers

    Giles

  • #6 / Oct 25, 2009 3:02pm

    Greg Salt

    3988 posts

    Hi Giles,

    Please let us know how you get on and whether you’ve resolved this issue.

    Cheers

    Greg

  • #7 / Feb 22, 2010 2:51pm

    vorari

    40 posts

    Hi Chaps,

    I have the exact same problem and I use Engine Hosting.  When using Mars Edit it tends to screw up the encoding of HTML with the case in point being a you tube link. 

    Is there any other way around this?  The custom field is set to “NONE”, And allow all HTML is enabled.

    Thanks,

  • #8 / Feb 22, 2010 4:07pm

    vorari

    40 posts

    I tried using the low_replace plugin - but I’m not sure my syntax is correct?

    Having an issue with Mars Edit/Metaweblog & EE 1.6.8. The code for the youtube gets corrupted.

    Specifically: ‘<’ and ‘>’ get converted to <and >respectively. (less than and greater than - can't get the actual code to show)
    So if you enter <object>blah blah and save it to EE, it immediately comes back as <object >blah blah

    I’m trying to use low_replace to solve this, but I’m wondering if I need a regex?

    {exp:low_replace find=”<|>” replace= “<|>” multiple=”yes”}
    {summary}
    {body} –> eg:<object width=”425″ height=”344″>
    {extended}
    {/exp:low_replace}

    Sorry.. not great with this - just trying to figure it out.

    Thanks,

  • #9 / Feb 22, 2010 5:20pm

    Ingmar

    29245 posts

    Can we try to take Mars Edit out of the equation here? What happens when you post via the regular Control Panel? You, too, have read the Wiki entries, I suppose?

  • #10 / Feb 22, 2010 5:42pm

    vorari

    40 posts

    Hi Ingmar,

    Yes I have reviewed the wiki entries.  It works perfectly when using EE.  It’s specific to using a 3rd party client: I’ve tried Mars Edit, Blogo and Ecto.  All exhibit this behaviour.

    What is problematic is that if anyone views or attempts to edit a post with an editor such an Mars Edit, the brackets ‘<’ and ‘>’ get converted to ‘lessthan;’ and ‘greaterthan;’ and the entire blog post as a result is messed up.

    In this thread and others it was suggested that this is a PHP issue.  EngineHosting are not using the problematic version detailed there and I’m open to using the exp:replace plugin or any other approach.

    It’s very easy to replicate this issue: Fire up MarsEdit, configure it as per EE guidelines (MetaWebLog API URL; MoveableType as the platform) and then paste any youtube embed code you can find.  Then save the post.  The moment this happens the preview within MarsEdit has changed and even on EE direct - the brackets have been removed. 

    Any suggestions would be most welcome.  (Fyi.. if it helps it looks like this a problem on 2.0 as well).

  • #11 / Feb 22, 2010 6:55pm

    Adam Dorsey

    1439 posts

    Out of curiosity vorari… The custom field text formatting is set to none, right?

    And to clarify, this is a problem with your Editor and not when posting directly in EE?

    Thanks!

  • #12 / Feb 22, 2010 8:06pm

    vorari

    40 posts

    Hi Adam,

    Correct.  The problem is exactly identical to the beginning of this post.  There are no problem if only using EE.  But MarsEdit / Ecto / Others are so well known I can’t believe I’m the only one running into this.  Using EE 1.6.8.

  • #13 / Feb 22, 2010 8:19pm

    Adam Dorsey

    1439 posts

    Hm - I’m going to move this to “How-to” then, as there is no issue with EE, but rather an external tool.

    Good luck, and Happy EE’ing!

  • #14 / Feb 22, 2010 8:29pm

    vorari

    40 posts

    Is there no one out that uses an offline editor - MarsEdit OR Ecto OR Blogo and run into this issue? I’m inclined to believe - based on the forums I’ve read that it was either a 1) PHP Server Issue (Engine Hosting isn’t using the problematic code I’m told) or 2) An EE Issue.  At this point when any of these editors save a post to EE and the proceeds to read the same entry again the tags are stripped. I’m inclined to believe this is an EE/PHP issue or other providers would likely have seen the same problem.

  • #15 / Feb 22, 2010 8:38pm

    Lisa Wess

    20502 posts

    Adam is right that this is likely an issue with an external editor, or perhaps the exchange.  It’s hard to say.  I’ve moved this back to technical support for a bit so we can try to narrow it down.

    Have you been in contact with the authors of those programs, by any chance, to get their take on it?

    Also, are you using “All HTML” or “Safe HTML”?

    And, what version and build of EE are you on, and using what extensions?

    Thanks.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases