Skip to content

Instantly share code, notes, and snippets.

@junichi11
Created July 29, 2011 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junichi11/1113193 to your computer and use it in GitHub Desktop.
Save junichi11/1113193 to your computer and use it in GitHub Desktop.
CakePHP MeioUploadHelper
<?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