Open aggied opened 9 years ago
You need to information when the user will save the content? Or right after fetching the embed so you can use it elsewhere in your application?
Maybe, you can tell us more about your use case so we can try to find the best implementation for that.
I need it when the user saves the content. I realize most use cases are satisfied by simply inserting the embed iframe, but I am also needing to store the metadata that comes back from iframely because I will also be extending the code to support more than just Youtube, etc. I need the ability for users to share virtually any link and have a preview generated much like takes place on Google+, Facebook, etc. My application prefers structured text over raw html.
I am currently accomplishing this by adding the following line of code at line 1074 of the plugin
html+='<div class="medium-insert-meta"><script type="text/json">'+JSON.stringify(data)+'</script></div>';
When the user saves the content, I am able to retrieve the metadata by grabbing that script element and parsing out the JSON. I imagine there is a better way of doing things, but I'd be happy to submit a PR if this seems like a good way to go about it.
I don't think this is something that everyone will need to have. But you can send a PR with that information and an option to enable that feature which will be disabled by default.
What do you think?
thanks for being open to it. Perhaps someone will benefit from it down the road. If I do get around to extending the plugin to handle embeds from more sites, I'm guessing folks my be interested in a PR for that?
@j0k3r @orthes
Jeremy, Pavel - we've just realized a conceptual problem with how embeds are implemented for the insert plugin. Maybe it's worth a separate ticket, but the work to fix has already started in this one. So I'll keep the thread.
The problem is simple: all JavaScript embeds are incorrect. For example, Twitter, Instagram, Facebook, Tumblr, Pinterest, Gists - all of those are JavaScript embeds.
Here's the workflow:
But Twitter doesn't #229. And so don't many-many others.
We need a way to pass the original HTML code to the server so that that one is used in the article.
Also, it may make sense to re-fresh the cache of embed code from time to time.
Thus, this ticket started by @aggied becomes very important.
We have had a number of customer support requests for this issue and should have guessed about the cause much earlier, but our own js embeds happen to work well in semi-rendered state, so it wasn't obvious.
Thoughts?
@iparamonau I use https://github.com/itteco/iframely on a server to generate quality embeds for an impressive amount of sites, so it is very important for me to store the resulting metadata. Also, I have a general bias towards storing structured metadata so I can easily change the display on my site and have it be backwards compatible with older content.
Have you tried the PR I submitted? Does it work for you?
After searching over the repo, I can't find anything that would indicate the plugin supports sending/storing the oembed response anywhere. I have a use case for storing this metadata along with the resulting iframe html.
Assuming this isn't already an available option, perhaps we could add to the Embed options a "responseCallback" function that sends the response of the oembed in? Or perhaps a storeEmbedMeta option that stores the stringifed json in a hidden value of the html somewhere?