Support » Fixing WordPress » Convert old youtube embed codes

  • Hi,

    Currently, i have thousands of articles with the old embed youtube code with flash technology, like this:

    <div class="video"><object width="425" height="344" data="" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="src" value="" /><param name="allowfullscreen" value="true" /></object></div>

    I want to switch to the most recent code with iframe, but i do not know how to do it massively. Is there any plugin to do it? Thanks

    • This topic was modified 1 year, 6 months ago by Steve Stern.
Viewing 1 replies (of 1 total)
  • Hi xopox,

    Looking at this, I’d recommend replacing your embed codes with a one-line video embed for each video. This is where you place the video URL on it’s own line in the content, and WordPress embeds the video for you.

    A filter on the_content would be a good way to start, with a regex to match all div tags with the video CSS class. From there, pulling the URL of the video out of the matched text, and replacing the div tag with the video URL, would achieve the desired result.

    This would also be non-destructive, as it doesn’t actually replace the content in the database, yet overrides the videos with new embeds.

    I hope this helps, as a starting point.

Viewing 1 replies (of 1 total)
  • The topic ‘Convert old youtube embed codes’ is closed to new replies.