Created
July 29, 2011 05:39
-
-
Save junichi11/1113193 to your computer and use it in GitHub Desktop.
CakePHP MeioUploadHelper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* CakePHP MeioUploadHelper | |
* Copyright (c) 2011 junichi11 | |
* @author junichi11 | |
* @license MIT | |
*/ | |
class MeioUploadHelper extends AppHelper { | |
//=============================================== | |
// property | |
//=============================================== | |
public $helpers = array('Html'); | |
public $settings = array( | |
'dir' => '/uploads/images/', | |
'thumbnailDir' => 'thumb', | |
); | |
public $view = null; | |
//=============================================== | |
// constructor | |
//=============================================== | |
function __construct($settings){ | |
if(!empty($settings)){ | |
$this->settings = am($this->settings, $settings); | |
} | |
$this->view = ClassRegistry::getObject('view'); | |
} | |
//=============================================== | |
// method | |
//=============================================== | |
public function image($filename, $options = null){ | |
$path = $this->settings['dir']; | |
if(isset($options['thumb'])){ | |
$path .= $this->settings['thumbnailDir'].'/'.$options['thumb'].'/'; | |
unset($options['thumb']); | |
} | |
$path .= $filename; | |
return $this->Html->image($path, $options); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment