/i', $post->post_content, $matches); $first_img = $matches [1] [0]; if(empty($first_img)){ //Defines a default image $first_img = ""; } return $first_img; } /* Get the first video form a post */ /* http://wordpress.stackexchange.com/questions/175793/get-first-video-from-the-post-both-embed-and-video-shortcodes */ function apollosegundo_get_first_embed_media($post_id) { $post = get_post($post_id); $content = do_shortcode( apply_filters( 'the_content', $post->post_content ) ); $embeds = get_media_embedded_in_content( $content ); if( !empty($embeds) ) { //check what is the first embed containg video tag, youtube or vimeo foreach( $embeds as $embed ) { if( strpos( $embed, 'video' ) || strpos( $embed, 'youtube' ) || strpos( $embed, 'vimeo' ) ) { return $embed; } } }else{ //No video embedded found return false; } } /* Responsive video embeds */ function apollosegundo_responsive_wrap_oembed( $html ){ $html = preg_replace( '/(width|height)="\d*"\s/', "", $html ); return'