Modifying the "catch_that_image()" function for videos
-
Hi there!
I′m using this function to get the images of the posts to above the post titles. This works great! But right now, I need to do exactly the same but with videos (for example Youtube), so, how should I do? Here I copy the function I′m using.[ Moderator note: please wrap code or markup snippets in backticks or use the code button. ]
function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = "/images/default.jpg"; } return $first_img; }
Please be good, I′m a Web Designer!:D
Thanks in advance!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Modifying the "catch_that_image()" function for videos’ is closed to new replies.