Search the blog

ProcessWire is an extremely powerful CMS; in terms of actually managing content it is definitely one of the best. I used to resize images in the front-end but this really slows the page load down for the first user to access a page since an image was updated.

As I do in cubed™, it is much better to resize images immediately after upload, in the CMS. This is accomplished via hooks.

Add this code to your site/templates/admin.php file before the require($config->paths->adminTemplates . 'controller.php'); line.

wire()->addHookAfter('InputfieldFile::fileAdded', function($event) {

    $inputField = $event->object;
    $image = $event->argumentsByName('pagefile');

    if ($inputField->name == 'myFieldName') {

        // Do whatever you want with $image here
        $image->size(1600, 900, ['upscaling' => true]);


    // Process other image fields here


The same hook is called for all images so you need to run code based on individual field names — myFieldName is used in the example.

Tim Bennett is a web designer and developer. He has a First Class Honours degree in Computing from Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.