WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 11 months ago

#17764 closed defect (bug) (worksforme)

TinyMCE breaks the autoembed feature

Reported by: dzver Owned by: 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 4 years ago.
17764.diff (889 bytes) - added by sushkov 3 years ago.

Download all attachments as: .zip

Change History (21)

@dzver4 years ago

comment:1 @nacin4 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 @dd324 years ago

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

comment:3 @dd324 years ago

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

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

comment:5 @ocean904 years ago

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

Also happens in 3.1.

comment:6 @hebbet4 years ago

Chrome 12 on windows and ubuntu does autolinking in tinymce.

comment:7 @dd324 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 @ocean904 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 @dzver4 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 @dd324 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 @hebbet4 years ago

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

comment:12 follow-up: @ocean904 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 @azaozz4 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: @azaozz4 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 @ocean904 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.

@sushkov3 years ago

comment:16 @sushkov3 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 @ocean903 years ago

#21915 was marked as a duplicate.

comment:18 @ocean9017 months ago

#26448 was marked as a duplicate.

comment:19 @wonderboymusic11 months 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.