/**
  * Fired once the record is saved, if there is a `open_layers_zoom_filename`
  * passed in the $_POST along with save then we know that we need to zoom
  * resource.
  */
 public function hookAfterSaveItem($args)
 {
     if (!$args['post']) {
         return;
     }
     $item = $args['record'];
     $post = $args['post'];
     // Loop through and see if there are any files to zoom.
     // Only checked values are posted.
     $filesave = false;
     $view = get_view();
     $creator = new OpenLayersZoom_Creator();
     $files = $creator->getFilesById($item);
     foreach ($post as $key => $value) {
         // Key is the file id of the stored image, value is the filename.
         if (strpos($key, 'open_layers_zoom_filename_') !== false) {
             $file = $files[(int) substr($key, strlen('open_layers_zoom_filename_'))];
             if (!$view->openLayersZoom()->isZoomed($file)) {
                 $creator->createTiles($value);
             }
             $filesaved = true;
         } elseif (strpos($key, 'open_layers_zoom_removed_hidden_') !== false && $filesaved != true) {
             $creator->removeZDataDir($value);
         }
     }
 }