title: Get YouTube Image from Embed iframe
body: <p>I have this embed iframe for youtube on my wordpress page.</p>
  
  <p>So I'm recreating every embed frame and I need to left only with two things: src and image</p>
  
  <p>I have regexp for geting src:</p>
  
  <pre><code>function youtube($html) {
      if (strpos($html, "&lt;iframe" ) !== false) {
          $frame = preg_match('/&lt;iframe.*?\/iframe&gt;/i', $html, $match2);
  
          $count = preg_match('/src=(["\'])(.*?)\1/', $match2[0], $match);
  
          var_dump($match);
      } else {
          return $html;
      }
  }
  add_filter('bp_get_activity_content_body', 'youtube', 10);
  add_filter('the_excerpt', 'youtube', 10);
  add_filter('the_content', 'youtube', 10);
  </code></pre>
  
  <p>So <code>$match</code> contains my src. but I stack with image, here is an iframe
  ( I also deleted script parts which in my opition will not do much )</p>
  
  <pre><code>&lt;iframe width="591" height="332" src="http://www.youtube.com/embed/1lws4QPUL7I?feature=oembed" frameborder="0" allowfullscreen=""&gt;
  #document
  &lt;html lang="en" dir="ltr" data-cast-api-enabled="true"&gt;
      &lt;head&gt;
          &lt;title&gt;Craig Ferguson   2013 06 20   Lewis Black, Matt Morales - YouTube&lt;/title&gt;
          &lt;link rel="canonical" href="http://www.youtube.com/watch?v=1lws4QPUL7I"&gt;
          &lt;link id="css-1394124665" class="www-embed-player" rel="stylesheet" href="http://s.ytimg.com/yts/cssbin/www-embed-player-webp-vflC5nNwO.css" data-loaded="true"&gt;
      &lt;/head&gt;
      &lt;body id="" class="date-20130829 en_US ltr   ytg-old-clearfix site-left-aligned exp-watch7-comment-ui webkit webkit-537" dir="ltr"&gt;
          &lt;div id="player" class="full-frame" style="width: 100%; height: 100%; overflow: hidden;"&gt;
              &lt;embed name="player1" height="100%" width="100%" id="player1" tabindex="0" type="application/x-shockwave-flash" src="http://s.ytimg.com/yts/swfbin/watch_as3-vfldizVp8.swf" allowscriptaccess="always" allowfullscreen="true" bgcolor="#000000" flashvars="user_display_name=Radikal%20Edward&amp;amp;iurl=http%3A%2F%2Fi1.ytimg.com%2Fvi%2F1lws4QPUL7I%2Fhqdefault.jpg&amp;amp;ldpj=-10&amp;amp;thumbnail_num_shards=1&amp;amp;rel=1&amp;amp;authuser=0&amp;amp;hl=en_US&amp;amp;probably_logged_in=1&amp;amp;iurlsd=http%3A%2F%2Fi1.ytimg.com%2Fvi%2F1lws4QPUL7I%2Fsddefault.jpg&amp;amp;length_seconds=2376&amp;amp;idpj=-2&amp;amp;cr=US&amp;amp;video_id=1lws4QPUL7I&amp;amp;is_html5_mobile_device=false&amp;amp;user_display_image=https%3A%2F%2Flh4.googleusercontent.com%2F-PcXCu3dRJSk%2FAAAAAAAAAAI%2FAAAAAAAAAAA%2FoIo6fJTO2X4%2Fs28-c-k%2Fphoto.jpg&amp;amp;allow_ratings=1&amp;amp;iurlmaxres=http%3A%2F%2Fi1.ytimg.com%2Fvi%2F1lws4QPUL7I%2Fmaxresdefault.jpg&amp;amp;fexp=939106%2C929117%2C929121%2C929906%2C929907%2C929922%2C929127%2C929129%2C929131%2C929930%2C936403%2C925726%2C925720%2C925722%2C925718%2C929917%2C906945%2C929933%2C920302%2C906842%2C913428%2C920605%2C919811%2C904830%2C919373%2C930803%2C908536%2C904122%2C938701%2C936308%2C909549%2C900816%2C912711%2C904494%2C904497%2C900375%2C906001&amp;amp;view_count=260&amp;amp;endscreen_module=http%3A%2F%2Fs.ytimg.com%2Fyts%2Fswfbin%2Fendscreen-vfl2YNgK7.swf&amp;amp;playlist_module=http%3A%2F%2Fs.ytimg.com%2Fyts%2Fswfbin%2Fplaylist_module-vflie7hg5.swf&amp;amp;enablejsapi=1&amp;amp;avg_rating=5&amp;amp;allow_embed=1&amp;amp;el=embedded&amp;amp;sk=puClsWoCKB-tDaeZo-YHXBSb1UkBB1wuC&amp;amp;feature=oembed&amp;amp;share_icons=http%3A%2F%2Fs.ytimg.com%2Fyts%2Fswfbin%2Fsharing-vflF4tO1T.swf&amp;amp;title=Craig%20Ferguson%20%20%202013%2006%2020%20%20%20Lewis%20Black%2C%20Matt...&amp;amp;sendtmp=1&amp;amp;abd=1&amp;amp;eurl=http%3A%2F%2Flocaldollars.ge%2F&amp;amp;playerapiid=player1&amp;amp;framer=http%3A%2F%2Flocaldollars.ge%2F"&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  &lt;/iframe&gt;
  </code></pre>
  
  <p>And also in the first part of my function, I want to check if the iframe belongs to youtube (because I have also different ones) and I only check for iframe</p>
  
  <pre><code> if (strpos($html, "&lt;iframe" ) !== false)
  </code></pre>
  
  <p>I didn't come up with regexp because width and height might change</p>