Make WordPress Core

Opened 13 years ago

Closed 10 years ago

#17764 closed defect (bug) (worksforme)

TinyMCE breaks the autoembed feature

Reported by: dzver's profile dzver Owned by: azaozz's profile azaozz
Milestone: Priority: normal
Severity: normal Version: 2.0
Component: Media Keywords: has-patch
Focuses: Cc:

Description

The auto embedding works with URLs on a separate line:

http://www.youtube.com/watch?v=e0Qt5CKdoOY

Right now the Visual Editor makes all URLs clickable:

<a href="http://www.youtube.com/watch?v=e0Qt5CKdoOY">http://www.youtube.com/watch?v=e0Qt5CKdoOY</a>

and auto embedding no longer works.

Reported here:

http://en.forums.wordpress.com/topic/embedding-video-does-not-work?replies=1

Attachments (2)

autoembed-core-diff.diff (958 bytes) - added by dzver 13 years ago.
17764.diff (889 bytes) - added by sushkov 13 years ago.

Download all attachments as: .zip

Change History (21)

#1 @nacin
13 years ago

  • Milestone changed from Awaiting Review to 3.2
  • Owner set to azaozz
  • Severity changed from normal to critical
  • Status changed from new to assigned

Sounds like a regression.

Posts don't have make_clickable, so the right fix here should be to disable said TinyMCE feature.

That said, entirely unrelated, it's always bugged me that a failed oEmbed doesn't make the URL a link.

#2 @dd32
13 years ago

I can't reproduce this in Opera (at least)

#3 @dd32
13 years ago

Ok, It's just that in opera, it doesn't auto link :) confirmed in IE.

Last edited 13 years ago by dd32 (previous) (diff)

#5 @ocean90
13 years ago

  • Severity changed from critical to normal
  • Version set to 3.1

Also happens in 3.1.

#6 @hebbet
13 years ago

Chrome 12 on windows and ubuntu does autolinking in tinymce.

#7 @dd32
13 years ago

Chrome 12 on windows and ubuntu does autolinking in tinymce.

Hmm, Chrome 12.0.742.91 on windows doesn't do it for me.

From what I can find, it is only related to IE and ContentEditable.

#8 @ocean90
13 years ago

Info to Chrome: If you copy the link from the omnibox and paste it to the editor it will be linked.

Maybe this can fix the problem:
http://stackoverflow.com/questions/687552/prevent-tinymce-internet-explorer-from-converting-urls-to-links/5459254#5459254

#9 @dzver
13 years ago

I reproduced the problem with Chrome 13 and Firefox 4.0.1. Try to copy/paste a Youtube link from youtube.com.

Copy/paste in TinyMCE doesn't work at all with my Opera 11.11/Win7.

#10 @dd32
13 years ago

yeah, as ocean90 pointed out, If you copy a url from within chrome and paste it, it treats it as a link, If you paste from say, opera, it treats it as text.

#11 @hebbet
13 years ago

tested with chromium 14: pasted url from ominbox is not autolinked in tinymce

#12 follow-up: @ocean90
13 years ago

I couldn't reproduce it in Firefox. But here is a workaround for Chrome:

function my_remove_a_tag( $init ) {
	$init['paste_preprocess'] = "function(pl, o) {o.content = o.content.replace( /<a[^>]*>(.*?)<\/a>/gi, '$1' );}";
	
	return $init;
}
add_filter( 'tiny_mce_before_init', 'my_remove_a_tag');

#13 @azaozz
13 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 3.2 to Future Release
  • Version changed from 3.1 to 2.0

This is not a regression, it's been around since we started using TinyMCE (WordPress 2.0) and yes, it is a feature in IE. In other browsers it depends on what you copy: if you copy "link location" it pastes it as text but if you copy linked text (that can be the actual URL) it pastes it as a link.

Both of the above patches would fix this in IE but at the same time would convert to text some links too. They also need to test whether the href == linked text. Perhaps doing this in PHP is better as we know what URLs to look for and only convert for them.

There is an easy workaround: after the URL is converted, click on it and click on "Remove Link" button. Since this is not critical bug or regression, moving to 3.3.

#14 in reply to: ↑ 12 ; follow-up: @azaozz
13 years ago

Replying to ocean90:

I couldn't reproduce it in Firefox. But here is a workaround for Chrome:

This will remove all links from pasted content that is undesirable. Quite a few people seem to paste in TinyMCE, we shouldn't break that.

#15 in reply to: ↑ 14 @ocean90
13 years ago

Replying to azaozz:

Replying to ocean90:

I couldn't reproduce it in Firefox. But here is a workaround for Chrome:

This will remove all links from pasted content that is undesirable. Quite a few people seem to paste in TinyMCE, we shouldn't break that.

In my tests it only replaces the a tags from the Chrome link. But my code should only be a hint, nothing serious.

@sushkov
13 years ago

#16 @sushkov
13 years ago

  • Cc stas@… added
  • Keywords has-patch dev-feedback added; needs-patch removed

Updated the patch. Regexp was ok, but it didn't work because of $match parameter.

#17 @ocean90
12 years ago

#21915 was marked as a duplicate.

#18 @ocean90
11 years ago

#26448 was marked as a duplicate.

#19 @wonderboymusic
10 years ago

  • Keywords dev-feedback removed
  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from assigned to closed

If you paste a YouTube URL now, like https://www.youtube.com/watch?v=ZqD-LPOWIT0, it will show a YouTube video. Sweet since [28358]. The example in this ticket is a dead video.

Note: See TracTickets for help on using tickets.