Title: multiple oembeds
Last modified: August 21, 2016

---

# multiple oembeds

 *  Resolved [Andrea Fercia](https://wordpress.org/support/users/afercia/)
 * (@afercia)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/multiple-oembeds/)
 * hi again,
    say you have multiple oembeds in your markup, e.g.:
 * [http://blip.tv/cranetv/illustrator-katie-scott-6617917](http://blip.tv/cranetv/illustrator-katie-scott-6617917)
 * [http://blip.tv/unrelated/episode-1-on-the-next-6637862](http://blip.tv/unrelated/episode-1-on-the-next-6637862)
 * [http://youtu.be/VXa9tXcMhXQ](http://youtu.be/VXa9tXcMhXQ)
 * tested in both textarea debugger and inside a post, and it always match the youtube
   one. Should match the first one.
 * Same for:
    [http://blip.tv/unrelated/episode-1-on-the-next-6637862](http://blip.tv/unrelated/episode-1-on-the-next-6637862)
 * [http://youtu.be/VXa9tXcMhXQ](http://youtu.be/VXa9tXcMhXQ)
 * it mathces the youtube one
 * And some for
    [http://blip.tv/unrelated/episode-1-on-the-next-6637862](http://blip.tv/unrelated/episode-1-on-the-next-6637862)
 * it matches the vimeo one.
 * [http://wordpress.org/plugins/video-thumbnails/](http://wordpress.org/plugins/video-thumbnails/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Sutherland Boswell](https://wordpress.org/support/users/sutherlandboswell/)
 * (@sutherlandboswell)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/multiple-oembeds/#post-4219462)
 * I guess I should clarify the video discovery process a bit. This happens because
   the plugin goes through providers one at a time to scan for videos, and stops
   at the first one it finds.
 * This means that it looks for the first YouTube video, then the first Vimeo video,
   then the first Facebook video, and so on. Originally the plugin was only designed
   for YouTube, but since adding other providers it doesn’t always get the first
   video. This may be fixed in the future but I want to make sure it doesn’t impact
   performance.
 *  Thread Starter [Andrea Fercia](https://wordpress.org/support/users/afercia/)
 * (@afercia)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/multiple-oembeds/#post-4219466)
 * hi, thx for you reply.
    Yes I know how it works, I can read code 🙂 That’s the
   whole point, currently your $regexes are compared to the $markup in the order
   you include the files. First one included is the one for youtube, so if $markup
   has multiple embeds, let’s say first vimeo and second youtube, it will check 
   first for youtube even if the embed is the last one. When it finds youtube, the
   match is done and it will stop, skipping the vimeo embed even if it’s the first
   one in the $markup. This looks not correct to me, because the “featured” video
   should always be the first one that editors put in the markup. Maybe you could
   try with PREG_OFFSET_CAPTURE and work with offsets but this would mean running
   all the regexes as first step then find the first offset, hence the performance
   concern you mentioned. Meanwhile, you could consider to inform your users stating
   in your documentation that currently it correctly works just if you have one 
   embed per post. Btw I really appreciate the effort you made to have so many providers
   🙂 Thx, regards Andrea
 *  Plugin Author [Sutherland Boswell](https://wordpress.org/support/users/sutherlandboswell/)
 * (@sutherlandboswell)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/multiple-oembeds/#post-4219476)
 * That was the solution I was thinking, and it may be ready. Would like a little
   testing before release, so you can download and try out the [dev branch here](https://github.com/suth/video-thumbnails/tree/dev).
 *  Thread Starter [Andrea Fercia](https://wordpress.org/support/users/afercia/)
 * (@afercia)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/multiple-oembeds/#post-4219479)
 * hi, yea seems it works
    but you should check how many times the match is run 
   it seems to me the match is run multiple times, one for each of the 12 set of
   regexes that’s because you have 12 provider files included, each one with its
   class and its $regexes maybe I would try to build a single array of all the regexes
   and run the match just once
 *  Plugin Author [Sutherland Boswell](https://wordpress.org/support/users/sutherlandboswell/)
 * (@sutherlandboswell)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/multiple-oembeds/#post-4219483)
 * Just released version 2.1 which includes the changes to ensure the video discovered
   is actually the first video.
 *  Thread Starter [Andrea Fercia](https://wordpress.org/support/users/afercia/)
 * (@afercia)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/multiple-oembeds/#post-4219484)
 * great 🙂 upgraded and starred

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘multiple oembeds’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/video-thumbnails_3e6f7f.svg)
 * [Video Thumbnails](https://wordpress.org/plugins/video-thumbnails/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/video-thumbnails/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/video-thumbnails/)
 * [Active Topics](https://wordpress.org/support/plugin/video-thumbnails/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/video-thumbnails/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/video-thumbnails/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Andrea Fercia](https://wordpress.org/support/users/afercia/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/multiple-oembeds/#post-4219484)
 * Status: resolved