public static function get_image_by_height($path, $height = "original") { if ($path instanceof File) { $image_file = $path; } else { $image_file = new File($path); } $image_dir = $image_file->getDirectory(); $full_cache_dir = new Dir(self::THUMBNAILS_DIR . $image_dir->getPath()); $full_cache_dir->touch(); $data = ImageUtils::get_image_data($image_file); if ($height == "original") { $thumb_folder = "original"; } else { if ($data["height"] > $height) { $thumb_folder = "__x" . $height; } else { $thumb_folder = "original"; } } if ($thumb_folder == "original") { return $image_file->getPath(); } $final_image_folder = new Dir(self::THUMBNAILS_DIR . $image_dir->getPath() . $thumb_folder); //copio l'immagine nella cache $final_image_folder->touch(); $thumbnail_image_file = $final_image_folder->newFile($image_file->getFilename()); if (!$thumbnail_image_file->exists()) { ImageUtils::resize_by_height($image_file, $thumbnail_image_file, $height); } return $thumbnail_image_file->getPath(); }