title: Replace part of HTML string with Javascript or PHP
body: <p>I need to replace part of the HTML tag for displaying YouTube videos:</p>
  
  <pre><code>&lt;div class="pretty-embed" data-pe-videoid="IL5AbXBqzwk" data-pe-fitvids="true"&gt;&amp;nbsp;&lt;/div&gt;
  </code></pre>
  
  <p>with direct link to YouTube image while keeping ID which is defined in data-pe-videoid attribute:</p>
  
  <pre><code>&lt;img src="http://img.youtube.com/vi/YiF7e7m2jPo/sddefault.jpg"&gt;
  </code></pre>
  
  <p>If I break it in two parts, I would need to replace </p>
  
  <pre><code>&lt;div class="pretty-embed" data-pe-videoid="
  </code></pre>
  
  <p>with</p>
  
  <pre><code>&lt;img src="img.youtube.com/vi
  </code></pre>
  
  <p>and </p>
  
  <pre><code>" data-pe-fitvids="true"&gt;&amp;nbsp;&lt;/div&gt;
  </code></pre>
  
  <p>with</p>
  
  <pre><code>/sddefault.jpg"&gt;
  </code></pre>
  
  <p>I'm looking for a solution with PHP or jQuery/vanilla JavaScript. I tried to experiment with PHP &amp; regular expression but without success.</p>
  
  <p>Any help would be appreciated.</p>