All pastes #399392 Raw Edit

XoneK

public php v1 · immutable
·published 2007-03-17 23:42 UTC
rendered paste body
//// Turns an URL from the [img] tag into an <img> tag or a <a href...> tag//function handle_img_tag($url, $is_signature = false){	global $lang_common, $pun_config, $pun_user;	$img_tag = '<a href="'.$url.'">&lt;'.$lang_common['Image link'].'&gt;</a>';	if ($is_signature && $pun_user['show_img_sig'] != '0')		$img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';	else if (!$is_signature && $pun_user['show_img'] != '0')	{		$ch = curl_init();$timeout = 5; // set to zero for no timeoutcurl_setopt ($ch, CURLOPT_URL, $url);curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);$file_contents = curl_exec($ch);curl_close($ch);$new_image = ImageCreateFromString($file_contents);imagejpeg($new_image, "temp.jpg",100);// Get new dimensions$myfilesize = getimagesize("temp.jpg");$width_orig = $myfilesize[0];$height_orig = $myfilesize[1];		if ($myfilesize)		{			$width = $myfilesize[0];			$height = $myfilesize[1];			$img_tag = '<img class="postimg" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';			if ($width > 550)			{				$img_tag = '<a href="'.$url.'" rel="lightbox">' . $img_tag . '</a>';			}		}		else		{			$img_tag = '<strong>error: image ' . $url . ' cannot be loaded.</strong>';		}	}