Location: PHPKode > projects > Kwalbum > kwalbum/include/funcGetImageCode.php
 * @version 2.2
 * @package kwalbum
 * @since 2.0 2008-08-20
require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/itemTypes.php';

 * Figure out what html to fill in where an image would go.
 * Create the code for either the resized or thumbnail version.
 * @param string $path where the file is
 * @param string $filename
 * @param int $type based on itemTypes.php
 * @param int $id ItemId
 * @param bool $resize if it is a resized version or not
 * @param string $description only needed if the item is of type
 * @param string $url to link to
 * @return string html code for a thumbnail or resized "image"
function GetImageCode($path, $filename, $type, $id,
	$resize = false, $description = '', $url = '')
	if ($url)
		$link1 = "<a href='$url'>";
		$link2 = "</a>";

	switch ($type)
		case JPEG_FILE:
		case GIF_FILE:
		case PNG_FILE:
			if (!file_exists(PICS_PATH . $path.($resize ? 'r/' : 't/').$filename))
				if (EDIT_MODE)
					$msg = '<div class="error"><b>'.$link1.'Missing ';
					if (JPEG_FILE == $type)
						$msg .= 'JPEG';
					elseif (GIF_FILE == $type)
						$msg .= 'GIF';
					elseif (PNG_FILE == $type)
						$msg .= 'PNG';
					return $msg.' File'.$link2.'</b></div>';
					return '<div class="error">'.$link1.'File Missing'.$link2.'</div>';
			if (HIDE_PATH)
				$pic_url = PAGE_URL.'f='.$id.'&amp;s='.($resize ? 2 : 1);
				$pic_url = PICS_URL . $path.($resize ? 'r/' : 't/').$filename;

			//TODO: getimagesize();
			return "<div class='thumbnail'>$link1<img src='$pic_url' alt='$filename' />$link2</div>";
			$msg = '<div class="textThumbnail thumbnail">';
			if ($resize)
				if (EDIT_MODE)
					$msg .= "<span id='desc'>$description</span>".
					(!$description ? '<input type="button" id="emptyDesc" value="Edit Description"/>':'');
					$msg .= $description;
				$msg .= $link1."Description<br/>Only$link2";
			return $msg.'</div>';
		case TEXT_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'Text<br/>File'.$link2.'</div>';
		case WMV_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'Windows<br/>Media<br/>Video'.$link2.'</div>';
		case DIVX_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'DivX<br/>Video'.$link2.'</div>';
		case MPEG_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'MPEG<br/>Video'.$link2.'</div>';
		case MP4_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'MPEG-4<br/>Video'.$link2.'</div>';
		case OGG_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'Ogg<br/>Audio'.$link2.'</div>';
		case MP3_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'MP3<br/>Audio'.$link2.'</div>';
		case WAV_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'Waveform<br/>Audio'.$link2.'</div>';
		case TEXT_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'Text<br/>File'.$link2.'</div>';
		case ZIP_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'Zip<br/>File'.$link2.'</div>';
		case HTML_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'HTML<br/>File'.$link2.'</div>';
		case XML_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'XML<br/>File'.$link2.'</div>';
		case GPX_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'GPS eXchange<br/>File'.$link2.'</div>';
		case ODS_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'OpenDocument<br/>Spreadsheet'.$link2.'</div>';
		case ODT_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'OpenDocument<br/>Text'.$link2.'</div>';
		case DOC_FILE:
			return '<div class="textThumbnail thumbnail">'.$link1.'MS Word<br/>Document'.$link2.'</div>';
			if ($resize)
				return $link1.'No resized version yet. Click for the full size.';
				return '<span class="textThumbnail thumbnail">'.$link1.'[No Thumbnail]'.$link2.'</span>';
Return current item: Kwalbum