Tag Info

Hot answers tagged

7

No, its not possible. $content_width is a theme-wide constant, and its set in functions.php before any of the query conditionals are set. $content_width is used to determine the intermediate image sizes in image_send_to_editor. The "large" image size will be set to the value of $content_width. If you need to modify those sizes on a per-category basis, you ...


7

Use the oembed_dataparse filter to modify the resulting HTML output by any given oembed call. Example: add_filter('oembed_dataparse','test',10,3); function test($return, $data, $url) { if ($data->provider_name == 'YouTube') { return "<img src='{$data->thumbnail_url}'>"; } else return $return; } Then putting this in a ...


7

I needed just this for a recent project, so here's my plugin! The code should be self-explanatory, but if there are any questions ask away. <?php /** * Plugin Name: oEmbed Featured Image * Plugin URI: http://wordpress.stackexchange.com/q/70752/1685 * Description: Automatically set the featured image if an oEmbed-compatible embed is found in the post ...


6

I'm assuming you are using WordPress' Embeds feature. Generally speaking wp_embed_defaults() gives you the information you need. A look at the source discloses the possibilities you have: 2017 /** 2018 * Create default array of embed parameters. 2019 * 2020 * The width defaults to the content width as specified by the theme. If the 2021 ...


5

Those are not really arguments like for YouTube, more of arguments for WordPress itself. One way to handle it would be to access your argument later inside of a filter and modify HTML output. Pass in arguments array: wp_oembed_get( 'http://www.youtube.com/watch?v=', array( 'autoplay' => 1 ) ); And filter: add_filter('oembed_result','oembed_result', ...


4

WP_oEmbed::data2html() has a filter, oembed_dataparse. You can use this to change the output, based on the extra data which is passed as the second parameter. Something like this for example: add_filter( 'oembed_dataparse', 'wpse17461_oembed_dataparse', 10, 3 ); function wpse17461_oembed_dataparse( $html, $data, $url ) { if ( FALSE !== strpos( $url, ...


4

Two things: WordPress' oEmbed implementation prefers and works better with JSON. To use XML, WordPress needs the simplexml library in PHP to be available. If it's not available, then you'd probably get the results you're seeing. It's getting the XML but can't parse it without simplexml, so... nothing happens. Best way to fix the problem: Stop trying to ...


4

Not entirely sure it is supposed to be used like this, but by analogue with the_content try this: add_filter('the_excerpt', array($wp_embed, 'autoembed'), 9);


4

The problem: The reason why this isn't working, is this part of the WP_Embed::shortcode() method: if( $post_ID ) { .... cut ... // Use oEmbed to get the HTML $html = wp_oembed_get( $url, $attr ); ... cut ... } When trying to autoembed with the Heartbeat API the $post_ID is null, so wp_oembed_get() is never activated. No Caching: ...


3

Another method can be like this, On the current post when you save look for youtube video in the content, if found save it to the transient 'videos' and the post_id (for the link to the post later) insted of regex im using parse_url() and parse_str() add_action( 'save_post', 'save_youtube_videos' ); function save_youtube_videos( $post_id ) { $saved = ...


3

I think that a better option will be re-size the video with CSS, supposing you have the container .video_index for the index of videos and .video_single for a single video entry, here is an example. .video_index iframe{ width: 250px; height: 170px; } .video_single iframe{ width: 500px; height: 360px; }


3

Yeah, the old story with (O)embeds and content width. As soon as there is repsonsiveness, the whole system falls apart. A solution, that might be of use is what we do in our themes: /** * Change the embed code, so we can apply awesome css shit * Called by filter "oembed_result" * * @author Hendrik Luehrsen * @since 1.0 * * @param $html string The ...


3

Without knowing more about your theme I can only hazard a few guesses. What are you inputting as an excerpt, what is the current output you are seeing for your excerpt, and what is the expected output? Are you seeing the URL show up in the excerpt, or is it being stripped? Oembed Are you being sure to scope in $wp_embed? global $wp_embed; add_filter( ...


3

Building a fake embed shortcode and then calling run_shortcode to do this makes no real sense. Try this instead: echo $wp_embed->shortcode(array(), $my_tour_video); Edit: Additionally, when I use your code on a test page, using that embed, I get no such error as you're describing. If you can come up with a reproducible test case, then it might be ...


3

You can filter the HTML output for oEmbed with oembed_result. Now test the HTTP host of the URL for www.youtube.com and add the parameter. The oEmbed result is cached in a post meta field to avoid too many requests. To update old posts I have added an activation helper that clears those cached content for Youtube embeds only. <?php # -*- coding: utf-8 ...


3

It appears I've been hoodwinked by my local setup & accidentally stopping connections to vimeo / youtube. This resulted in the video url appearing as only text. Once my setup was restarted everything appears to be working properly. Sorry for the confabulation.


3

I assume that you're only interested in the first URL that actually succeeds at discovering actual oembed data. The oembed system processes all links it finds, but not every link will have oembed going for it, obviously. The filter you'll want to use is embed_oembed_html and it gets the HTML cached by oembed, the url, any attributes on the embed, and the ...


3

wp-includes/class-oembed.php has a public variable $providers. So you can build a small function to get all of them: function list_oembed_providers( $print = TRUE ) { require_once( ABSPATH . WPINC . '/class-oembed.php' ); $oembed = _wp_oembed_get_object(); $print and print '<pre>' . htmlspecialchars( var_export( $oembed->providers, ...


3

Looking into WordPress Core vimeo is registered like so: '#http://(www\.)?vimeo\.com/.*#i' => array( 'http://www.vimeo.com/api/oembed.{format}', true ), But looking at vimeo API for oEmbed they show their URL without the www. so what you need to do is register vimeo oEmbed correctly: add_action( 'init', 'add_vimeo_oembed_correctly' ); function ...


3

The embed_oembed_html filter runs before an oEmbed resource's HTML is outputted, so you could hook into this and wrap the output in a div as below. I can't think of a simple way of wrapping the other content. add_filter('embed_oembed_html', 'my_embed_oembed_html', 99, 4); function my_embed_oembed_html($html, $url, $attr, $post_id) { return '<div ...


3

Just use the [embed] shortcode around your items. <ul> <li>[embed]http://www.youtube.com/link/to/content[/embed]</li> ...


2

You can try this: add_filter( 'embed_oembed_html', 'custom_youtube_oembed' ); function custom_youtube_oembed( $code ){ if( stripos( $code, 'youtube.com' ) !== FALSE && stripos( $code, 'iframe' ) !== FALSE ) $code = str_replace( '<iframe', '<iframe class="youtube-player" type="text/html" ', $code ); return $code; } to target ...


2

All you need to do use apply_filters. foreach ($video as $vid) { echo '<li>'.apply_filters('the_content',$vid).'</li>'; } It may be more efficient to concatenate a string and then run the filter on the whole thing. $lis = ''; foreach ($video as $vid) { $lis .= '<li>'.$vid.'</li>'; } echo apply_filters('the_content',$lis); ...


2

It doesn't have to do with the theme. Flickr oEmbed is returning an image file which name ends with _n.jpg, and effectively it has a width of 320px. The bigger version ends with _b.jpg The filter hook that we need to use is embed_oembed_html. The following manipulates the result of the returning html to increase the image size, check the comments: ...


2

There is bit of special filtering by WP_Embed class that turns standalone links into target for embedding: /** * Passes any unlinked URLs that are on their own line to {@link WP_Embed::shortcode()} for potential embedding. * * @uses WP_Embed::autoembed_callback() * * @param string $content The content to be searched. * @return string Potentially ...


2

I just return the frame id using an each function: jQuery('#video-gallery-list li.video-player').each(function() { var iframeID = jQuery(this).find('iframe').attr('ID'); // do what you want with the iframeID });


2

Interesting Question, but quoting Mike Schinkel answering a similar Q: You could hook the save_post action, use WP_Http class to download it and then insert it as an attachment using wp_insert_attachment and wp_update_attachment_metadata(). It's not trivial but shouldn't be that hard. My emphasis. In another Q, Milo and Chris_O posted some ...


2

When you're referring to using oEmbed codes, I'm assuming that you're referring to WordPress' ability to take a URL to media (such as one from YouTube) and automatically embed that into a post. If that's the case, then you can take advantage of the embed_oembed_html hook that WordPress provides. Here's how you can do it with a custom function: function ...


2

You're probably best off using echo apply_filters( 'the_content', html_entity_decode( $monster_tiny_1 ) ); instead of echo wpautop(html_entity_decode($monster_tiny_1)); and similar, which will run the autoembed behavior.


2

I threw together a quick plugin version of this fix, which you can download from http://sct.temple.edu/blogs/it/2011/10/13/vimeo-embeds-issue-resolved/.



Only top voted, non community-wiki answers of a minimum length are eligible