当我使用此功能创建具有指定链接的图像时,它不直接显示刷新后它出现
http://mysite.local/img/slide-image-321.jpg/369x360
是图片的链接
private function generate_cache($localpath, $from, $to, $width, $height) {
$tempFrom = pathinfo($from);
$tempTo = pathinfo($to);
$tempPathFrom = $localpath.$tempFrom['basename'];
$tempPathTo = $localpath.$tempTo['basename'];
// Amazon S3
$awsAccessKey = Zend_Registry::getInstance()->config->amazons3->awsAccessKey;
$awsSecretKey = Zend_Registry::getInstance()->config->amazons3->awsSecretKey;
$bucketName = Zend_Registry::getInstance()->config->amazons3->bucketName;
$s3 = new Zend_Service_Amazon_S3($awsAccessKey, $awsSecretKey);
// ..
if(file_get_contents('http://'.$bucketName.'.s3.amazonaws.com/'.$tempFrom['basename'])) {
$content = file_get_contents('http://'.$bucketName.'.s3.amazonaws.com/'.$tempFrom['basename']);
}
if(!file_put_contents($tempPathFrom, $content)){
echo "Failed to copy the file";
}
$resize = $this->_helper->imgResize($tempPathFrom);
$resize->resizeImage($width, $height);
$resize->saveImage($tempPathTo, 95);
if(!$s3->putFile($tempPathTo, $bucketName."/".$tempTo["basename"])){
echo "failed to put the resized image in s3";
} else {
// Deleting the local files
unlink($tempPathTo);
unlink($tempPathFrom);
}
}