Foros del Web » Programando para Internet » PHP »

Ayuda con funcion

Estas en el tema de Ayuda con funcion en el foro de PHP en Foros del Web. Hola tengo el siguiente codigo, y me gustaria poder llamar $video_id de la siguiente manera: <?php print($video_id); ?> tengo que crear otra funcion? o la ...
  #1 (permalink)  
Antiguo 17/11/2009, 02:27
 
Fecha de Ingreso: noviembre-2009
Mensajes: 1
Antigüedad: 14 años, 4 meses
Puntos: 0
Ayuda con funcion

Hola tengo el siguiente codigo, y me gustaria poder llamar $video_id de la siguiente manera: <?php print($video_id); ?> tengo que crear otra funcion?
o la variable que quiero (la id de youtube) es otra? estoy algo perdido. aqui os dejo el codigo:


Código:
<?php 

function print_video_thumb_backward($post, &$thumb_url) {

	$video_id = get_post_meta($post->ID, 'vids', true);

	if (! empty($video_id)) {	

			$thumb_url = 'http : / /img.youtube.com/vi/' . $video_id . '/2.jpg';

                        
			return 1;

	}

}







function print_video_thumb_supported_site($post,&$thumb_url) {

	$content = $post->post_content;

	if (preg_match(video_pattern(),$content, $match)) {

		// video found

		$content = $match[0];

		preg_match('/^\[(\w+)/',$content,$video_type);

		switch ($video_type[1]) {

			case 'youtube':
                                preg_match('/v=(.*?)[\s&\[]/',$content,$video_id);

				$url = 'h t t p : / / youtube.com/v/' . $video_id[1];

    		$data = get_url($url);


				preg_match('/v=(.*?)[\s&\[]/',$content,$video_id);
                                $thumb_url = 'h t t p : / / img.youtube.com/vi/' . $video_id[1] . '/2.jpg';

				return 1;

}

	}

}



function print_video_thumb_custom_field($post,&$thumb_url) {

	$t = get_post_meta($post->ID, 'video_thumb', true);

	if (! empty($t)) {

		$thumb_url = $t;

		return 1;

	}

}



function print_video_thumb_first_post_image($post,&$thumb_url) {

	$content = $post->post_content;

	if (preg_match('/<img[[:alnum:]\s-_=;:"\/]+src="(.*?)"/',$content, $match)) {

		$thumb_url = $match[1];

		return 1;

	}

}



function print_video_thumb_unsupported_site($post,&$thumb_url) {

	$content = $post->post_content;

	if (preg_match(video_pattern(),$content, $match)) {

		// video found

		$content = $match[0];

		preg_match('/^\[(\w+)/',$content,$video_type);

		switch ($video_type[1]) {

			case 'myspace':

				$thumb_url = get_template_directory_uri() . '/images/thumb_myspace.png';

				return 1;

		}

	}

}



function print_video_thumb($post) {

	print_video_thumb_backward($post,$thumb_url)

	 || print_video_thumb_custom_field($post,$thumb_url)

	 ||	print_video_thumb_supported_site($post,$thumb_url)

	 ||	print_video_thumb_first_post_image($post,$thumb_url)

	 || print_video_thumb_unsupported_site($post,$thumb_url);

	echo get_video_thumb(get_permalink($post->ID), $post->post_title,

					$thumb_url);

}



function get_video_thumb($url,$title,$img) {

	return '<a href="' . $url . '" title="' . $title . '"><img src="' .

		$img . '" alt="' . $title . '" width="130px" height="97px" /></a>';

}

?>
  #2 (permalink)  
Antiguo 17/11/2009, 09:02
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Tema movido desde Configuración a PHP
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:44.