Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#12048 closed enhancement (duplicate)

<video> tag is deleted when switching between Visual/HTML editors.

Reported by: cabel's profile cabel Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9.1
Component: Editor Keywords: tinymce
Focuses: Cc:

Description

SUMMARY:
I'm trying to embed a new HTML5 style video in a post. But it's very difficult, as the Wordpress Editor is continually deleting my <video> HTML when I switch over to Visual to do some writing.

STEPS TO REPRODUCE:

  1. Start a new post. Write a few words.
  2. Switch to "HTML"
  3. Paste in the following code:

<video width="700" height="394" controls autobuffer="false"><source src="http://example.com/example.m4v" type="video/mp4" /></video>

  1. Switch to "Visual". (A large white space for the video should be present.)
  2. Switch back to "HTML".

EXPECTED RESULTS:
Nothing happens. My <video> tag remains and my code and post is unchanged.

ACTUAL RESULTS:
The entire <video> tag, and its contents, is gone!

WORKAROUNDS:
None that I can find, except to never touch the "Visual" tab, which is challenging...

Change History (7)

#1 @azaozz
15 years ago

  • Milestone changed from Unassigned to Future Release
  • Priority changed from high to normal
  • Severity changed from major to normal
  • Type changed from defect (bug) to enhancement

The problem is that most currently used browsers do not support HTML 5 yet (IE, older FF and WebKit, etc.) so if you add <video> or <audio> tags most visitors to the site won't see them.

Currently the visual editor uses XHTML 1 doctype and tags. There is an update in the works for it to support some HTML 5 tags that should be available soon. If you want to experiment with <video> now, I'd suggest adding a small plugin:

<?php

add_filter('tiny_mce_before_init', 'my_video_tags');
function my_video_tags($settings) {
  if ( !empty($settings['extended_valid_elements']) )
    $settings['extended_valid_elements'] .= ',';
  else
    $settings['extended_valid_elements'] = '';

  $settings['extended_valid_elements'] .= 'video[*],audio[*]'; // add other HTML 5 tags as needed

  return $settings;
}

#2 @cabel
15 years ago

Thanks so much for taking the time to look at my bug.

First, I'm not totally sure I would call this an "enhancement" request as I'm literally losing data every time I edit or open this post. Switching to "Visual" at any point should never, in my opinion at least, delete large chunks of your crafted HTML and replace it with nothing at all. Sounds like a great preference, at least -- "Preserve unknown HTML". Wait, that's an enhancement request, isn't it? Nuts.

(I only say this because I keep forgetting about the situation, and I keep going to edit tiny things on that post, and it keeps wiping out the video entirely, and I keep not noticing until later, and I keep having to revert. Anyway.)

Fortunately, as we're a Mac software house, our users are predominately <video> capable. After posting a <video> video, we received literally zero comments that the video couldn't be seen. Hooray. The time is now! :)

Thanks for the suggestion on the plug-in front. I'll look into it now.

#3 @ninjaWR
15 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

#4 @nacin
15 years ago

  • Milestone Future Release deleted

#5 @dd32
15 years ago

  • Resolution changed from duplicate to fixed

(In [14160]) Remove double-query for Author ID. Props simonwheatley. Fixes #12048

#6 @dd32
15 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#7 @dd32
15 years ago

  • Resolution set to duplicate
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.