本文整理汇总了PHP中sfImage::setMIMEType方法的典型用法代码示例。如果您正苦于以下问题:PHP sfImage::setMIMEType方法的具体用法?PHP sfImage::setMIMEType怎么用?PHP sfImage::setMIMEType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfImage
的用法示例。
在下文中一共展示了sfImage::setMIMEType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generates a thumbnail.
*
* The generation is actually done by the sfImageTransformPlugin. This method only collects the
* options configured in the thumbnailing.yml and uses them to call sfImageTransformPlugins transformations.
* Additionally the generated thumbnail can be cached.
*
* @param string $uri Image source URI (sfImageSource://...)
* @param array $options Thumbnail parameters taken from the thumbnail URL referencing a format and id
* @return sfImage
*/
public function generate($uri, $format)
{
if (!array_key_exists($format, $this->options['formats'])) {
throw new sfImageTransformExtraPluginConfigurationException('Unknown format "' . $format . '" in your thumbnailing.yml!');
}
$sourceImage = new sfImage($uri);
$settings = $this->options['formats'][$format];
if (array_key_exists('mime_type', $settings)) {
$sourceImage->setMIMEType($settings['mime_type']);
}
if (is_array($settings['transformations'])) {
foreach ($settings['transformations'] as $transformation) {
$this->transform($sourceImage, $transformation);
}
}
$sourceImage->setQuality($settings['quality']);
return $sourceImage;
}