All pastes #760181 Raw Edit

Untitled

public php v1 · immutable
·published 2007-11-03 20:24 UTC
rendered paste body
<?phpfunction product_image_tag($id, $width=150, $height=150){	$outfile = '/cache/'.$id."_{$width}x{$height}.jpg";	if (!file_exists(sfConfig::get('sf_upload_dir').$outfile)) {		return sprintf('<img src="%s">', '/'.sfConfig::get('sf_upload_dir_name').$outfile);	}		$infile = '/products/'.$id.'.jpg';	if (!file_exists(sfConfig::get('sf_upload_dir').$infile)) {		return;	}	// Retrieve the name of the uploaded file	$thumbnail = new sfThumbnail($width, $height);	$thumbnail->loadFile(sfConfig::get('sf_upload_dir').$infile);		$thumbnail->save(sfConfig::get('sf_upload_dir').$outfile, 'image/jpeg');		return sprintf('<img src="%s">', '/'.sfConfig::get('sf_upload_dir_name').$outfile);}