Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<?php
$text = "<img src='body.jpg' alt='' border='0' />";
preg_match("/src=[\'\"]{1}(.*?)[\'\"]{1}/", $text, $matches);
$image = getimagesize($matches[1]);
if($image[0]>=500){
$text =preg_replace("/\[img\](.+?)\[\/img\]/s", '<img src="$1" width="500">',$text);
} else {
$text =preg_replace("/\[img\](.+?)\[\/img\]/s", '<img src="$1">',$text);
}
?>
<?php
$text = "";![]()
preg_match("/\[img\](.+?)\[\/img\]/si", $text, $matches);
$image = getimagesize($matches[1]);
if($image[0]>=500){
$text =preg_replace("/\[img\](.+?)\[\/img\]/s", '<img src="$1" width="500" />',$text);
} else {
$text =preg_replace("/\[img\](.+?)\[\/img\]/s", '<img src="$1" />',$text);
}
echo $text;
?>
function tagimg($m)
{
$m[1] = str_replace(' ', '%20', $m[1]);
if ($size = @getimagesize($m[1]))
{
list($width, $height) = $size;
$width = ($width > 500) ? 500 : $width;
return '<img src="' . $m[1] . '" width="' . $width . '" height="' . $height . '" border="0" />';
}
return $m[0];
}
$text = preg_replace_callback('/\[img\](?!.*?\[img\].*?)(.*?)\[\/img\]/i', 'tagimg', $text);
sry за забавения отговор, но това е идеално(как не се сетих не знам), давам ти 1005-тата точкаemagi каза:Най-правилния вариант е:
<?php
$text = "";![]()
preg_match("/\[img\](.+?)\[\/img\]/si", $text, $matches);
$image = getimagesize($matches[1]);
if($image[0]>=500){
$text =preg_replace("/\[img\](.+?)\[\/img\]/s", '<img src="$1" width="500" />',$text);
} else {
$text =preg_replace("/\[img\](.+?)\[\/img\]/s", '<img src="$1" />',$text);
}
echo $text;
?>