本文整理汇总了PHP中Varien_Image::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Image::getMimeType方法的具体用法?PHP Varien_Image::getMimeType怎么用?PHP Varien_Image::getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Image
的用法示例。
在下文中一共展示了Varien_Image::getMimeType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateUploadFile
/**
* Check - is this file an image
*
* @param string $filePath
* @return bool
* @throws Mage_Core_Exception
*/
public function validateUploadFile($filePath)
{
if (!getimagesize($filePath)) {
Mage::throwException($this->__('Disallowed file type.'));
}
$_processor = new Varien_Image($filePath);
return $_processor->getMimeType() !== null;
}
示例2: validateUploadFile
/**
* Check - is this file an image
*
* @param string $filePath
* @return bool
* @throws Mage_Core_Exception
*/
public function validateUploadFile($filePath)
{
if (!getimagesize($filePath)) {
Mage::throwException($this->__('Disallowed file type.'));
}
$adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType();
$_processor = new Varien_Image($filePath, $adapter);
return $_processor->getMimeType() !== null;
}
示例3: createPreviewImage
/**
* Create preview image
*
* @param string $imagePath
* @return string
*/
public function createPreviewImage($imagePath)
{
$adapter = Mage::helper('Mage_Core_Helper_Data')->getImageAdapterType();
$image = new Varien_Image($imagePath, $adapter);
$image->keepTransparency(true);
$image->constrainOnly(true);
$image->keepFrame(true);
$image->keepAspectRatio(true);
$image->backgroundColor(array(255, 255, 255));
$image->resize(self::PREVIEW_IMAGE_WIDTH, self::PREVIEW_IMAGE_HEIGHT);
$imageName = uniqid('preview_image_') . image_type_to_extension($image->getMimeType());
$image->save($this->_getImagePathPreview(), $imageName);
$this->setPreviewImage($imageName);
return $imageName;
}
示例4: validateUploadFile
/**
* Check - is this file an image
*
* @param string $filePath
* @return bool
* @throws Mage_Core_Exception
*/
public function validateUploadFile($filePath)
{
$maxDimension = Mage::getStoreConfig(self::XML_NODE_PRODUCT_MAX_DIMENSION);
$imageInfo = getimagesize($filePath);
if (!$imageInfo) {
Mage::throwException($this->__('Disallowed file type.'));
}
if ($imageInfo[0] > $maxDimension || $imageInfo[1] > $maxDimension) {
Mage::throwException($this->__('Disalollowed file format.'));
}
$_processor = new Varien_Image($filePath);
return $_processor->getMimeType() !== null;
}