如果該文件只存在於文件夾結構,但並不像concrete5文件對象,你需要的FileImporter
第一:
use Concrete\Core\File\Importer;
$fi = new Importer();
if($fv = $fi->importIncomingFile($themePath . '/' . $filename)){
$returnFile = \Concrete\Core\File\File::getByID($fv->getFileID());
}
然後你可以將那個文件對象的getThumbNail()
功能。該getThumbNail()
不走的路徑,但圖像對象作爲第一個參數:
$imageHelper = Core::make('helper/image');
$thumbnail = $imageHelper->getThumbnail($returnFile, 300, 9999, false);
下面是採取(從API)所有PARAMS:
/**
* Returns a path to the specified item, resized and/or cropped to meet max width and height. $obj can either be
* a string (path) or a file object.
* Returns an object with the following properties: src, width, height
* @param mixed $obj
* @param int $maxWidth
* @param int $maxHeight
* @param bool $crop
*/
public function getThumbnail($obj, $maxWidth, $maxHeight, $crop = false)
難道我的回答您解決問題? –