Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Adding FlexVideo automatically? Any idea? #500

Closed
dantahoua opened this issue Oct 6, 2015 · 6 comments
Closed

Adding FlexVideo automatically? Any idea? #500

dantahoua opened this issue Oct 6, 2015 · 6 comments

Comments

@dantahoua
Copy link
Contributor

Hello.
Would be great to find a way to "hook" the auto-embed wordpress function so when someone put a youtube video in the editor it's automatically put in a flex video...
https://codex.wordpress.org/Embeds
Any idea? I can't find any doc on it...

@dantahoua
Copy link
Contributor Author

Ok I found it finally! Maybe would be good to add it to the library folder!
add_filter('embed_oembed_html', 'my_embed_oembed_html', 99, 4); function my_embed_oembed_html($html, $url, $attr, $post_id) { return '<div class="flex-video widescreen">' . $html . '</div>'; }

@arielnoname
Copy link

I was using this little piece of code with jquery:

$('iframe[src*="youtube.com"]').wrap("<div class='flex-video'/>");

You can change it if you want Vimeo, for example

$('iframe[src*="vimeo.com"]').wrap("<div class='flex-video'/>");

Cheers

@JeremyEnglert
Copy link

@dantahoua - that works great for videos, but it also adds the code to Twitter embeds, which makes them look a bit odd. I wish there was a way to target just videos with that filter.

@arielnoname - that works like a charm. You can also do something like this to make sure you target YouTube and Vimeo:

jQuery( 'iframe[src*="youtube.com"], iframe[src*="vimeo.com"]' ).wrap("<div class='flex-video'/>");

@arielnoname
Copy link

Really nice @JeremyEnglert . I'm not a big jQuery guy, didn't know one could pick more than one selector. Cheers

@dantahoua
Copy link
Contributor Author

Thanks, love it! I didn't notice for tweeter because I didn't use it on this website, but good to know! I'll use the jquery method.

@olefredrik
Copy link
Owner

Fixed #620

(Note that vimeo embeds will require an extra vimeo class)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants