Código PHP:
<?
function img_size($url,$type) {
// Empiezo el proceso para archivar el tamaño y dimensiones de la imágen
list($width, $height) = getimagesize($url);
if($type == 'width') {
if($width > '504') $width = '504';
elseif($width <= '504') $width = $width;
return $width;
}
if($type == 'height') {
if($height > '378') $height = '378';
elseif($height <= '378') $height = $height;
return $height;
}
}
$a = array(
"/\[i\](.*?)\[\/i\]/is",
"/\[b\](.*?)\[\/b\]/is",
"/\[u\](.*?)\[\/u\]/is",
"/\[center\](.*?)\[\/center\]/is",
"/\[left\](.*?)\[\/left\]/is",
"/\[right\](.*?)\[\/right\]/is",
"/\[img\](.*?)\[\/img\]/is",
"/\[url=(.*?)\](.*?)\[\/url\]/is",
"/\[url](.*?)\[\/url\]/is",
"/\[quote=(.*?)\](.*?)\[\/quote\]/is",
"/\[quote](.*?)\[\/quote\]/is",
"/\[youtube](.*?)\[\/youtube\]/is",
"/\[vimeo](.*?)\[\/vimeo\]/is"
);
$b = array(
"<i>$1</i>",
"<b>$1</b>",
"<u>$1</u>",
"<center>$1</center>",
"<left>$1</left>",
"<right>$1</right>",
"<img src=\"$1\" style=\"width:".img_size(strtoupper("\\1"),"width").";height:".img_size(strtoupper("\\1"),"height").";margin:auto;\" />",
"<a href=\"$1\">$2</a>",
"<a href=\"$1\">$1</a>",
"<div class=\"quote\">Cita:<br/> <div class=\"bgquote\">Empezado por: <b>$1</b><br/> <font style=\"font-size:10px;\"><i>$2</i></font></div></div>",
"<div class=\"quote\">Cita:<br/> <div class=\"bgquote\">Empezado por alguién:<br/> <font style=\"font-size:10px;\"><i>$1</i></font></div></div>",
"<object style=\"height: 390px; width: 640px\">
<param name=\"movie\" value=\"http://www.youtube.com/v/$1?version=3\">
<param name=\"allowFullScreen\" value=\"true\">
<param name=\"allowScriptAccess\" value=\"always\">
<embed src=\"http://www.youtube.com/v/$1?version=3\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowScriptAccess=\"always\" width=\"640\" height=\"390\"></object>",
"<object style=\"height: 300px; width: 400px\">
<param name=\"movie\" value=\"http://player.vimeo.com/video/$1\">
<param name=\"allowFullScreen\" value=\"true\">
<param name=\"allowScriptAccess\" value=\"always\">
<embed src=\"http://player.vimeo.com/video/$1\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowScriptAccess=\"always\" width=\"400\" height=\"300\"></object>"
);
// con modificador
echo preg_replace($a, $b, '[img]http://a3.sphotos.ak.fbcdn.net/hphotos-ak-ash4/184727_1885408622011_1445276233_32089958_459342_n.jpg[/img]');
?>
Sigo teniendo errores:
La imagen la muestra, pero arriba lista este error:
Cita: Warning: getimagesize(\1) [function.getimagesize]: failed to open stream: No such file or directory in C:\AppServ\www\CulturaBahiense\prueba.php on line 5
Warning: getimagesize(\1) [function.getimagesize]: failed to open stream: No such file or directory in C:\AppServ\www\CulturaBahiense\prueba.php on line 5