• Hi, I’m running WordPress 2.3.3 and having trouble when embedding videos to posts. For example, whenever I add the HTML code for a YouTube video (using the “Code” tab in the WordPress editor), all of the HTML code for the video is gone or messed up after Saving. Sometimes, instead of stripping out all of the embed, object and param HTML tags, it messes it all by adding paragraph (p) tags in between. This does not happen with other HTML tags such as links, images, etc. The strange thing is that I would expect the behavior of the “Code” tab to respect my HTML mark-up.

    I would really appreciate any ideas on how to solve this issue. Ideally, I would like to upload HTML code through the “Code” tab and have WordPress respect it.

    Thanks,
    Ralph

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter rachochlac

    (@rachochlac)

    UPDATE: I noticed that if I switch the user’s permission from “Author” to “Editor”, it now saves the HTML mark-up for embedding a video. Does anyone know where on the PHP scripts I could change this behavior so that “Authors” can also add HTML mark-up?

    Also, another bug is that whenever I want to add a video, I first have to disable the visual editor from the “Profile” screen. Otherwise, the post editor messes up the HTML code when Saving.

    Any ideas will be appreciated.

    Thanks again,
    Ralph

    ndmaque

    (@ndmaque)

    Ralph — same problem

    They are using tiny mce as the html editor, it has a config file found in wp-admin/js/edit.js

    i havent the full answer right now but tiny mce may be where the answer lies. (the receiving post.php page doesnt strip tags by the looks of it so it has to be the javascript part of the html editor itself wp-admin/post.php.

    I know Tiny mce can enble / disable certain tags and ignore/delete others, so we need to edit the ‘allowed list’ so its not stripped, a similar list dictates what html gui icons show in your gui edit panel for things like add link, bold, add table etc … so this problem is all about indentyfing which one edit and add the param and embed tags to!
    There is much help on tinymce

    example area of interest in edit.js

    29)// Pretty it up for the source editor
    30) var blocklist1 = ‘blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|pre|p’;

    its such pipe seperated tag lists that enable/disable features showing or working, i added object|embed to the above but it didnt help.

    i tried removing the if wrapper on lines 55-58 like shown as it mentions the embed/object tags but it didnt help so i’m stumped, if you get the answer pls post it back for all to see!

    to work around i just put the http:youtube/etc/v=GHF776 text in the post and walk the dom with javascript looking for a matching pattern on the page and extract the v=value and wrap it in a piece of embed code!
    document.write(“<object name=movie value=v><embed>stuff</embed></object>”)

    not a good solution but works for me.

    // if ( content.indexOf(‘<object’) != -1 ) {

    content = content.replace(new RegExp(‘\\s*<param([^>]*)>\\s*’, ‘mg’), “<param$1>”);
    content = content.replace(new RegExp(‘\\s*</embed>\\s*’, ‘mg’), ‘</embed>’);

    //}

    I also added the tag names onto the 2 blocklists at line 30 and 159 like shown but again no change.

    var blocklist1 = ‘blockquote|ul|ol|li|table|thead|tbody|tr|th|td|div|h[1-6]|pre|p|embed|object’;

    var blocklist = ‘table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]|embed|object’;

    Embedding video works well in 2.5. Also pasting the page url of youtube video in the “Media” popup in TinyMCE embeds it properly.

    ndmaque

    (@ndmaque)

    that means giving high level permissions tho doesn’t it?

    I want any user to add youtubes to their post

    I think you’ll need to look into the kses functions/filters to allow that.

    Hi everyone,

    I’m using wordpress 2.6.2, I cannot embed any kinds of videos as well.

    For example I am trying to embed a youtube video. I cut and paste the video url into the “add video” dialogue box. I save the blog and view it. Instead of seeing the video I see this: watch?v=nbTVtAdaw9s

    Now I’ve used wordpress.com before and I have no problems at all.

    I’ve searched the forums here for solutions and tried the suggestions from fellow forum members. Though some of the suggestions seem to work for others for some reason it doesn’t work for me. Maybe because I am using wordpress 2.6.2

    I am a complete newbie to wordpress so the easier the solution the better.

    Any help would be greatly appreciated.

    I had a problems embedding Youtube videos in blog postings in a previous version of WordPress (not sure which one exactly) but it was resolved in the latest version 2.6.3.

    All you need to do is when making a post ensure that the view is in the HTML view (tab in the top right hand corner of editor) and simply paste in the ’embed code’ from the youtube video you want to show in your blog.

    Worked well for me!

    Hope this helps.

    Thanks AntOny,

    Yeah I tried the pasting the embed code in HTML screen already. But I still have the same problem. Maybe I have to upgrade to 2.6.3.

    I’ll try that and see what happens.

    Nope I upgraded to 2.6.3 and I still cannot embed a youtube video.
    Wordpress turns the youtube url into a hyperlink. Both the wysiwg and html editors give me the same results.

    It’s really weird. Anybody have any ideas?

    Thanks

    I am having this same problem as well. VERY Frustrating. The screencast shows this working perfectly, and it’s a total disaster for me whether I use the “Embed video” function or I try to paste the raw embed code.

    It just dissapears.

    This is an issue with the wordpress roles. The roles of Editor and Administrator can post Unfiltered HTML, the rest of the roles cannot. The best solution I have found is a plugin that allows you to apply custom capabilities to an individual user or role. More info here or download the Role Manager Plugin.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Cannot embed external video: HTML code not working’ is closed to new replies.