WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 2 years ago

#15490 closed enhancement (fixed)

Preview oEmbed results when using the media modal to insert from URL

Reported by: filosofo Owned by:
Milestone: 4.0 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: Cc:

Description

If you insert a video URL via the "Add media file from URL" popup, it should do the following:

  • Determine whether the URL is oEmbed-able, and if so, insert the appropriate shortcode into the post.
  • Create a corresponding attachment with something indicating that it's a video in the post_mime_type field (even though we're not really dealing with true MIME types). That way, we can query video attachments, agnostic of where the actual video file exists.

Attachments (5)

15490.diff (5.3 KB) - added by jtsternberg 4 years ago.
This successfully displays an oembed preview when an oembed url is detected. Still needs a proper nonce passed for the ajax action.
15490.2.diff (5.0 KB) - added by helen 4 years ago.
15490.3.diff (4.1 KB) - added by wonderboymusic 3 years ago.
15490.4.diff (4.2 KB) - added by jtsternberg 3 years ago.
Removes width/height inputs, and improves the styling of the oEmbed items in responsive views.
15490.5.diff (4.5 KB) - added by wonderboymusic 3 years ago.

Download all attachments as: .zip

Change History (40)

#1 @jtsternberg
4 years ago

  • Cc justin@… added
Version 0, edited 4 years ago by jtsternberg (next)

#2 @jtsternberg
4 years ago

A feature discussed in [IRC today]https://irclogs.wordpress.org/chanlog.php?channel=wordpress-dev&day=2013-01-31&sort=asc#m544868 that would be a nice addition: Showing a preview in the modal if an oembed url is added.

#3 @helen
4 years ago

  • Milestone changed from Future Release to 3.6

On the "Insert from URL" panel in the media modal:

nacin: so, A) detect oEmbed provider URLs, B) showing a preview of said video in the process, C) ensuring it gets inserted on its own line (force a line break) would complete this feature.

#4 @jtsternberg
4 years ago

And one more reference link: [pre 3.6 post format overhaul user-testing]http://make.wordpress.org/ui/2013/01/31/have-made-it-through-the-second-round-of/

#5 follow-up: @jtsternberg
4 years ago

Should this same functionality apply to all supported and applicable oEmbed urls? i.e. Tweets, slideshare, polldaddy, etc. Or should this only apply to the traditional "media" types like video/audio?

#6 in reply to: ↑ 5 ; follow-ups: @DrewAPicture
4 years ago

Replying to jtsternberg:

Should this same functionality apply to all supported and applicable oEmbed urls? i.e. Tweets, slideshare, polldaddy, etc. Or should this only apply to the traditional "media" types like video/audio?

I feel like it would be a nice-to-have but may fall outside the scope of the ticket. Setting it up for video-only at least initially would be a good test case.

#7 in reply to: ↑ 6 ; follow-up: @helen
4 years ago

Replying to DrewAPicture:

I feel like it would be a nice-to-have but may fall outside the scope of the ticket.

Without actually functionally writing code, I can't promise this, but it seems to me that if we're already detecting if it's an oEmbed provider and retrieving the response, it doesn't matter whether it's video, audio, a tweet, or something else.

#8 @jtsternberg
4 years ago

I implemented very similar functionality with Custom Metaboxes and Fields for WordPress and plan on using that as a base for incorporating to WP for this ticket, but if anyone wants to take a look at the code and take a stab at it before I get time, hopefully that will help point you in the right direction.

#9 in reply to: ↑ 6 @jtsternberg
4 years ago

Replying to DrewAPicture:

Replying to jtsternberg:

Should this same functionality apply to all supported and applicable oEmbed urls? i.e. Tweets, slideshare, polldaddy, etc. Or should this only apply to the traditional "media" types like video/audio?

I feel like it would be a nice-to-have but may fall outside the scope of the ticket. Setting it up for video-only at least initially would be a good test case.

In the case of the CMB script, it really made no difference what the oembed content was, so I THINK we can do the same here.

@jtsternberg
4 years ago

This successfully displays an oembed preview when an oembed url is detected. Still needs a proper nonce passed for the ajax action.

#10 in reply to: ↑ 7 @jtsternberg
4 years ago

  • Keywords has-patch added; needs-patch removed

As Helen pointed out in IRC, I think the next item to tackle is to remove the auto-linking when adding to a post via the media window. (which keeps the oEmbed from working on the front-end)

@helen
4 years ago

#11 @gcorne
4 years ago

  • Cc gregory@… added

#12 @sabreuse
4 years ago

.2 is working nicely for me at embedding/previewing from the modal.

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

#13 @helen
4 years ago

Two things I want to see, besides nonce and removing auto-linking when a valid response is returned:

  • Testing usage of the Ajax action outside of the modal (looks like it'll work just fine, but would still like a test).
  • Thoughts on how we can deal with caching the retrieved data to stay away from rate limit problems. Right now all oEmbed caches are dumped on pre_post_update and then re-requested, which already makes it extremely easy to hit, say, Twitter's rate limit of 150 per hour per IP, especially on shared hosting. May very well be outside the scope of this ticket itself, but would at least like to see what thoughts might be.

#14 @helen
4 years ago

  • Summary changed from Better Remote Video Insert to Preview oEmbed results when using the media modal to insert from URL

#15 @DrewAPicture
4 years ago

  • Cc xoodrew@… added

#16 @ryan
4 years ago

  • Milestone changed from 3.6 to Future Release

#17 @taylorde
3 years ago

  • Cc td@… added

#18 @helen
3 years ago

#24762 was marked as a duplicate.

#19 @helen
3 years ago

#22548 was marked as a duplicate.

This ticket was mentioned in IRC in #wordpress-ui by helen. View the logs.


3 years ago

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.


3 years ago

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.


3 years ago

#23 @wonderboymusic
3 years ago

  • Milestone changed from Future Release to 4.0

15490.3.diff refreshes the Backbone pieces and leans on [28358] for the auto-parsing of [embed] in TinyMCE

#24 @jtsternberg
3 years ago

I'm thinking we should remove the width/height inputs from the 'embed-link-settings' template. It's not applicable to all oembed types and it's probably not worth adding an if/else/switch statement to determine if they should be conditionally added. Also those widths should default to the [$content_width](http://codex.wordpress.org/Content_Width) global.

Thoughts? I'll provide a diff in case we're in agreement.

@jtsternberg
3 years ago

Removes width/height inputs, and improves the styling of the oEmbed items in responsive views.

#25 @jtsternberg
3 years ago

Last diff also contains css improvements. I tested at a window width of 645px and tested these oEmbed endpoints:

  • flickr
  • videopress (videopress)
  • wordpress.tv
  • vimeo
  • slideshare
  • imgur
  • youtube
  • instagram
  • twitter

#26 @jtsternberg
3 years ago

One other thing I forgot to mention re: 15490.4.diff. I removed the width/height inputs from the template for reasons stated above, and on top of those, there was nothing written to handle the data entered in the width/height inputs.

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.


3 years ago

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.


3 years ago

#29 @wonderboymusic
3 years ago

  • Owner filosofo deleted
  • Status changed from new to assigned

#31 @wonderboymusic
3 years ago

In 28581:

When adding a URL in the Insert from URL state in the media modal, attempt to show a preview of the content. Drop the unused width and height fields.

This will probably be iterated upon.

Props helen, jtsternberg, wonderboymusic.
See #15490.

#32 @SergeyBiryukov
3 years ago

Is there a need for global $post in wp_ajax_send_link_to_editor()?

#33 @wonderboymusic
3 years ago

$post is pre-existing. There are probably a bunch of places where it is imported and never used. I will scan.

#34 @wonderboymusic
3 years ago

Yes, it is required. $post (the global) is set later on down the road, $wp_embed requires it. If it is removed, the preview is correct, but a link is inserted into the editor.

#35 @wonderboymusic
2 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

We are showing preview now, there are other tickets that address specifics.

Note: See TracTickets for help on using tickets.