Make WordPress Core

Opened 10 years ago

Last modified 7 years ago

#30720 new enhancement

In editor, add a button to refresh/invalidate (oEmbed) embeds cache

Reported by: ivanp's profile ivanp Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.0
Component: Embeds Keywords: needs-patch
Focuses: ui Cc:

Description

The inline embeds previews in WP4.0 are great, however have one major flaw:

One user enters the URL, and preview is generated via oEmbed, the embed code is cached for a day for that URL. There is no way for the author to invalidate it.

It generally works well, but not when user wants to experiment with different oEmbed-related plugins or settings. To keep great function, yet make it more straightforward for the user to control the flow, I'd suggest the following.

Shall we add a button "reload" to the inline previews of the embeds? And/or "reload" button in the Edit Embed dialog?

I trust it is a great answer to the problem and fits the user experience well.

We are the authors of Iframely plugin. The supports issues we get since WP4.0 mostly relate to oEmbed cache. But such approach will also answer the needs of other devs and users, for example #30282.

Attachments (2)

2014-12-15_10-43-18.jpg (227.7 KB) - added by ivanp 10 years ago.
suggested UI - 1
2014-12-15_10-46-27.jpg (272.0 KB) - added by ivanp 10 years ago.
suggested UI - 2

Download all attachments as: .zip

Change History (16)

@ivanp
10 years ago

suggested UI - 1

@ivanp
10 years ago

suggested UI - 2

#1 follow-up: @helen
10 years ago

Reloading/refreshing an individual embed is interesting to me, although I'm not sure it's a huge issue across the board for most users. I'd probably look at doing it within your plugin for the time being. Open to thoughts, though.

#2 @ivanp
10 years ago

It's not just about our plugin. I believe this function will resolve many other issues across the board. We saw users with tech knowledge invalidating the cache directly in the DB to answer their various use cases. But that's the power users. The regular editors will be happy to get this function too.

As to our plugin particularly, I am proud with the way it currently smoothly integrates into native WP functions so that the solution is future-proof for any changes you guys make in the core. Well, except this approach stumbled in 4.0 where the core assumed that embeds won't change, whereas it is not the case. There are various other plugins that let people customize YouTube options, etc. Even changing system-wide maxwidth parameter would require embeds to be re-query-ed (whereas I think it's not the case at the moment)

As it stands, the core gives a user the control over everything except embeds previews. I believe it should be improved :)

#3 @ivanp
10 years ago

Here's more simple solution that doesn't require the UI changes.

Simply, when user clicks on X to remove the embedURL from the post, delete the URL's embed code from meta. That would work too as many people try this as workaround but don't get the behaviour they expect.

#4 @swissspidy
9 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Simply, when user clicks on X to remove the embedURL from the post, delete the URL's embed code from meta.

That sounds reasonable to me. I'll try to have a look at it.

#5 @kranzoky
8 years ago

The only problem I can foresee is that if there is an issue with an Oembed, then the URL just ends up being a normal URL in the editor, so you wouldn't be able to click on the embed or have the "Insert from URL" dialogue box appear in order to refresh the Oembed cache.

You can see the issue here: https://core.trac.wordpress.org/ticket/32553

The issue I ran into is that sometimes just one or two URLs would get corrupted in a post and wouldn't convert over to embeds correctly (they would at first but then for some reason would stop). And then I had to use a plugin called Oembed Cache to clear the Oembed cache for that specific post to get everything working again.

So I am wondering if there is some way to just have a button/link appear somewhere when there are Oembeds within the post that says something like "Refresh Oembed Cache"?

Version 1, edited 8 years ago by kranzoky (previous) (next) (diff)

#6 @kranzoky
8 years ago

I keep randomly getting _oembed meta_key values of "{{unknown}}". Then I have to clear the Oembed cache so that they return to normal again.

#7 @kranzoky
8 years ago

So maybe a solution to handle corrupt Oembed caches would be to check for {{unknown}} caches when the caches are retrieved. If an {{unknown}} is found, then clear it.

#8 @kranzoky
8 years ago

Any updates on this?

#9 @swissspidy
8 years ago

So maybe a solution to handle corrupt Oembed caches would be to check for {{unknown}} caches when the caches are retrieved. If an {{unknown}} is found, then clear it.

So basically that would mean not caching {{unknown}}. Don't think that's an option.

The only problem I can foresee is that if there is an issue with an Oembed, then the URL just ends up being a normal URL in the editor, so you wouldn't be able to click on the embed or have the "Insert from URL" dialogue box appear in order to refresh the Oembed cache.

We might be able to change this so that the URL will still be in a wpView like a working embed. That way you could still click on the "X" to clear the cache.

That is probably the most unobtrusive way, as I wouldn't add a big ol' button saying "Clear oEmbed cache" which the user has no clue of.

@iseulde @azaozz How feasible would it be to have a wpView for non-working embeds that have been turned into a link?

#10 @kranzoky
8 years ago

@swissspidy - Why would not caching {{unknown}} not be an option? If {{unknown}} is the value of an oEmbed, shouldn't that continually be checked anyway instead of cached since that should never be a desired oembed result?

#11 @azaozz
8 years ago

We might be able to change this so that the URL will still be in a wpView like a working embed.

Sure, that is doable. Currently we return the same error for both "non-embeddable" URLs and "embeddable" URLs that return errors. This can be changed to show different error message for the "embeddable" URLs, perhaps asking the user to "try again later". These errors can be in wpViews too.

Why not caching {{unknown}} is not an option?

Because the embed code runs on the front-end and can be very very slow sometimes.

#12 @kranzoky
8 years ago

@azaozz - That makes sense regarding not caching {{unknown}}.

However, could the system periodically (daily?) check for {{unknown}} values and then clear them out in order to make sure any corrupt oEmbed caches get fixed/cleared?

If not, I will basically have to create my own script that will run daily in order to fix those issues.

#13 in reply to: ↑ 1 @mcdonna
8 years ago

Replying to helen:

Reloading/refreshing an individual embed is interesting to me, although I'm not sure it's a huge issue across the board for most users. I'd probably look at doing it within your plugin for the time being. Open to thoughts, though.

I just spent 30 minutes trying to figure out why a video still overwrote half the page after installing the iFramely plugin, which has always worked well in the past. Thankfully I found the answer in one of the many support answers they've given to other people with the same problem. I was able to go into the database and delete _oembed_ postmeta to force WP to re-generate the embed code.

I really appreciate the efforts to find a solution! :)

Donna

This ticket was mentioned in Slack in #core by swissspidy. View the logs.


7 years ago

Note: See TracTickets for help on using tickets.