protected function resizedImagePath($field, $width, $height)
{
// get the parts for this file string
$info = $this->MediaPaths->fileVersionInfo($field->values->image);
// create resizedImagePath
$resizedImagePath = "{$info->versiondir}/{$info->filename}_{$width}_{$height}.{$info->ext}";
// resize the versioned image
$image = $this->Images->resizeImage($info->filepath, $width, $height);
// save this resized image
$this->Images->saveImage($image, $resizedImagePath);
// remove temporary image file if there is one
if ($info->tempfile) {
unlink($info->tempfile);
}
// finally return this image path as a string so we can store it
return $this->MediaPaths->makeRelativePath($resizedImagePath);
}