<?php
namespace Tags;

class img implements ITagProcessor {
	public static function Process($args, $content) {
		if (!isset($args['id']))
			return false;
		
		$id=$args['id'];
		$showTitle=!isset($args['title']) || $args['title']=="true";
		unset($args['id'],$args['title']);
		
		$image=new \Image($id);
		if (is_null($image->Path))
			return "<strong>Image not found</strong>";
		
		if (!isset($args['alt']))
			$args['alt']=$image->ImageTitle;
				
		$html='<div class="image">';
		$html.='<img src="/'.$image->Path.'"';
		foreach ($args as $k=>$v)
			$html.=' '.$k.'="'.$v.'"';
		$html.='/>';
		if ($showTitle)
			$html.='<span>'.$image->ImageTitle.'</span>';
		$html.='</div>';
		
		return $html;
	}
}
