Last active
January 31, 2017 13:08
-
-
Save somatonic/5685631 to your computer and use it in GitHub Desktop.
create thumbs when uploading image
This file contains 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 | |
class ImageCreateThumbs extends WireData implements Module { | |
public static function getModuleInfo() { | |
return array( | |
'title' => 'ImageCreateThumbs', | |
'version' => 100, | |
'summary' => '', | |
'href' => '', | |
'singular' => true, | |
'autoload' => true | |
); | |
} | |
public function init() { | |
$this->addHookAfter('InputfieldFile::fileAdded', $this, 'sizeImage'); | |
} | |
public function sizeImage($event) { | |
$inputfield = $event->object; | |
if($inputfield->name != 'images') return; | |
$image = $event->argumentsByName("pagefile"); | |
$image->size(120,120); | |
$image->size(1000,0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment