14

The Media Library in WordPress has "Insert from URL" link to the left. It accepts image URLs. It's not said anywhere but if you paste YouTube URL or <iframe> code then it will insert it too. It just won't show the preview like it does with image URLs so you can't tell if the code you typed in is valid or not.

  1. I'd like to edit this page and make it show previews of valid WordPress Embeds and of valid <iframes>. I want it to just show basic information that the embed code was recognized, is valid and can be inserted. I can write all the AJAX requests to validate URLs but I need help with wp.media object. I have no idea how to update that page or replace it with my own page? So far I've found /wp-includes/js/media-editor.js where on line 1054 it says Called when 'Insert From URL' source is not an image. Example: YouTube url..
  2. Secondly, once it's already done, I'd like to be able to call something like the following piece of code to open the Media Library with "Insert from URL" page selected and with the code added (for users to modify the existing code).

The code (this is a working example of how to bring a window for editing images but I need this for "Insert from URL"):

frame = wp.media({
    frame: 'image',
    state: 'image-details',
    metadata: { 'url': 'some-url' }
});
frame.open();
  • 3
    Something similar was introduced in WordPress recently and will be available in 3.9. See: make.wordpress.org/core/2014/03/11/… – swissspidy Mar 12 '14 at 18:48
  • Wow, that's really awesome news. I was really missing such feature. Thank you for that information! This question is still open though - it would be nice to find out how to add more sections like that or edit existing sections (say I'll want to add captions as custom output for YouTube players and this feature won't be included in 3.9). – Tom Mar 12 '14 at 20:37
  • 1
    Hey Tom, just found an example how you could do this: github.com/staylor/example-thing – swissspidy Apr 17 '14 at 18:48
-2

You might found something in here useful https://github.com/ericandrewlewis/wp-media-javascript-guide. Using Dropbox uploader i tried creating something similar. I hope this helps you out

  • Hello, Welcome to WordPress SE. This is a question and answer site not a forum. We prefer answers are definitive whereas this is more of a comment. Whoever downvoted this should really have explained that. Consider editing your answer to explain why the guide might help and how it applies to the question. – Matthew Brown aka Lord Matt Sep 2 at 0:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.