protected function rename($args) { $result = parent::rename($args); $path = $this->getPath($args['target']); $name = $args['name']; // If the image has a corresponding Visual, update its .path field and rename its thumbnail. $v = Visual::get_by_path($path); if ($v) { $dir = dirname($v->path); $v->path = $dir == '.' ? $name : "{$dir}/{$name}"; $v->save(); } return $result; }