0

我正在使用干预图像和他的缓存扩展干预图像缓存它工作得很好。

我想要做的是用标题和干预将图像缓存在浏览器上。

实现这一目标的最佳方法是什么?

假设我有一条路线,它将一个方法连接到我的控制器,该方法处理显示图像的响应,如下所示:

public function showImage($name_image)
    {
        // how can set the headers for get image cache on browser?
        $img = Image::cache(function($image) use ($name_image) {
               return $image->make('myFolderPathImage'."/".$name_image);
            });

        return Response::make($img, 200, array('Content-Type' => 'image/jpeg'));
    }
4

1 回答 1

0

你上面的代码对我来说效果很好,虽然这里有一些 laravel 4.2 路线的代码,它可能会有所帮助。

Route::get('/image/{image}', function($id) {
 if (!File::exists('public/img/g_icons/'.$id)) return Response::view('errors.missing', array(), 404);
 $img = Image::cache(function($image) use ($id) { $image->make('public/img/'.$id); },10080);
 return Response::make($img, 200, array('Content-Type' => 'image/png'));
});
于 2015-03-09T19:58:45.757 回答