本文整理汇总了PHP中IOHelper::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP IOHelper::getMimeType方法的具体用法?PHP IOHelper::getMimeType怎么用?PHP IOHelper::getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOHelper
的用法示例。
在下文中一共展示了IOHelper::getMimeType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMimeType
/**
* @return mixed
*/
public function getMimeType()
{
if (!$this->_mimeType) {
$this->_mimeType = IOHelper::getMimeType($this->getRealPath());
}
return $this->_mimeType;
}
示例2: __construct
/**
* Constructor
*
* @param null $imagePath
* @param null $imageUrl
*/
public function __construct($imagePath = null, $imageUrl = null)
{
if ($imagePath != 'null') {
$this['path'] = $imagePath;
$imageInfo = @getimagesize($imagePath);
$this['width'] = $imageInfo[0];
$this['height'] = $imageInfo[1];
$this['extension'] = IOHelper::getExtension($imagePath);
$this['mimeType'] = IOHelper::getMimeType($imagePath);
$this['size'] = IOHelper::getFileSize($imagePath);
}
if ($imageUrl != 'null') {
$this['url'] = $imageUrl;
}
}
示例3: getUrl
/**
* Get cropped image url.
*
* @param null|array $settings
*
* @return string
*/
public function getUrl($settings = null)
{
// Get image
$file = $this->getFile();
// Do the cropping
$this->applyCrop($file, $settings);
// Get base64 of crop
$base64 = $this->getBase64($file);
// Get mime
$mime = IOHelper::getMimeType($file);
// Delete the temp image
IOHelper::deleteFile($file);
// Return base64 string
return 'data:' . $mime . ';base64,' . $base64;
}
示例4: __construct
/**
* Constructor
*
* @param null $imagePath
* @param null $imageUrl
*/
public function __construct($imagePath = null, $imageUrl = null, $paths = null, $transform = null)
{
if ($imagePath != 'null') {
$this['path'] = $imagePath;
$this['extension'] = IOHelper::getExtension($imagePath);
$this['mimeType'] = IOHelper::getMimeType($imagePath);
$this['size'] = IOHelper::getFileSize($imagePath);
$imageInfo = @getimagesize($imagePath);
if (is_array($imageInfo) && $imageInfo[0] !== '' && $imageInfo[1] !== '') {
$this['width'] = $imageInfo[0];
$this['height'] = $imageInfo[1];
} else {
// Couldn't get size. Calculate size based on source image and transform.
$sourceImageInfo = @getimagesize($paths->sourcePath . $paths->sourceFilename);
$sourceSize = new \Imagine\Image\Box($sourceImageInfo[0], $sourceImageInfo[1]);
$targetCrop = craft()->imager->getCropSize($sourceSize, $transform);
$this['width'] = $targetCrop->getWidth();
$this['height'] = $targetCrop->getHeight();
}
}
if ($imageUrl != 'null') {
$this['url'] = $imageUrl;
}
}
示例5: getMimeType
/**
* @return string
*/
public function getMimeType()
{
return IOHelper::getMimeType($this->filename);
}
示例6: _validateImage
/**
* Validates that temp file is actually an image file
*
* @param string $remoteImagePath url of remote image
* @param string $tempLocalImage file pointer to temp image
*
* @return boolean
*/
private function _validateImage($remoteImagePath, $tempLocalImage)
{
// Check to make sure the asset is an image
if (IOHelper::getFileKind(IOHelper::getExtension($tempLocalImage)) === 'image' && substr(IOHelper::getMimeType($tempLocalImage), 0, 5) === 'image') {
return true;
}
return false;
}
示例7: _uploadFile
/**
* Upload a file to Rackspace.
*
* @param $targetUri
* @param $sourceFile
*
* @return bool
*/
private function _uploadFile($targetUri, $sourceFile)
{
$fileSize = IOHelper::getFileSize($sourceFile);
$fp = fopen($sourceFile, "r");
$headers = array('Content-type: ' . IOHelper::getMimeType($sourceFile), 'Content-length: ' . $fileSize);
$curlOptions = array(CURLOPT_UPLOAD => true, CURLOPT_INFILE => $fp, CURLOPT_INFILESIZE => $fileSize);
$targetUri = $this->_prepareRequestURI($this->getSettings()->container, $targetUri);
$this->_doAuthenticatedRequest(static::RACKSPACE_STORAGE_OPERATION, $targetUri, 'PUT', $headers, $curlOptions);
fclose($fp);
return true;
}