WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 5 months ago

#17764 assigned defect (bug)

TinyMCE breaks the autoembed feature

Reported by: dzver Owned by: azaozz
Milestone: Future Release Priority: normal
Severity: normal Version: 2.0
Component: Media Keywords: has-patch dev-feedback
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 3 years ago.
17764.diff (889 bytes) - added by sushkov 2 years ago.

Download all attachments as: .zip

Change History (20)

dzver3 years ago

comment:1 nacin3 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.

comment:2 dd323 years ago

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

comment:3 dd323 years ago

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

Version 0, edited 3 years ago by dd32 (next)

comment:5 ocean903 years ago

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

Also happens in 3.1.

comment:6 hebbet3 years ago

Chrome 12 on windows and ubuntu does autolinking in tinymce.

comment:7 dd323 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.

comment:8 ocean903 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

comment:9 dzver3 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.

comment:10 dd323 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.

comment:11 hebbet3 years ago

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

comment:12 follow-up: ocean903 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');

comment:13 azaozz3 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.

comment:14 in reply to: ↑ 12 ; follow-up: azaozz3 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.

comment:15 in reply to: ↑ 14 ocean903 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.

sushkov2 years ago

comment:16 sushkov2 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.

comment:17 ocean9019 months ago

#21915 was marked as a duplicate.

comment:18 ocean905 months ago

#26448 was marked as a duplicate.

Note: See TracTickets for help on using tickets.