Skip to content

Instantly share code, notes, and snippets.

@somatonic
Last active January 31, 2017 13:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save somatonic/5685631 to your computer and use it in GitHub Desktop.
Save somatonic/5685631 to your computer and use it in GitHub Desktop.
create thumbs when uploading image
<?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