How to change the size of video with php

Published on  by Gearloose ‐ In  ‐ Reading time: less than a minute
How to change the size of video with php

If you use php on your site and share video from Youtube or vimeo, see how you can change their size easily, without changing every single post.

Let's say you have a post and it contains an embed code from Youtube. You will going to pass the post's content into a variable named $post.

Using the preg_replace function we'll change the size of the video.

This way will always keep the videos in one size, which is ideal if you have a lot of posts and you don't want to change them manually.

$post= preg_replace('/(width)=("[^"]")/i', 'width="600"', $post);
$post= preg_replace('/(height)=("[^"]
")/i', 'height="400"', $post);


Related Posts

How to Set Up Multiple Blogs Using a Single CMS
Ethereum mining for Windows 7/10 - How To
How to connect your ps4 controller to your android mobile
How to build a Raspberry Pi Entertainment System in NES case