2

根据问题标题,我正在使用 Laravel 的干预包。我的路由文件中有以下代码:

Route::get('resize-image/{pathkey}/{filename}/{w?}/{h?}', function($pathkey, $filename, $w=100, $h=100){

    $cacheimage = Image::cache(function($image) use($pathkey, $filename, $w, $h){

        switch($pathkey){
            case 'tour-images':
                $filepath = 'upload/tour-images/' . $filename;
                break;
        }
        return $image->make($filepath)->resize($w,$h);

    },10,true); // cache for 10 minutes

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

当我使用以下方式调用图像时:/resize-image/tour-images/139326085726.jpg/1100/400它运行良好,然后一旦我重新加载页面,就会收到错误消息:

图像 xxxx 无法显示,因为它包含错误

如果我更改尺寸(因此强制它再次调整图像大小),它可以工作,那么......同样的问题。当我重新加载页面时,它应该是这次加载的缓存图像......但它不起作用。怎么了?

4

1 回答 1

3

好的,现在它正在工作。如果我删除'true',那么它会起作用,即。更改这行代码:

},10,true); // cache for 10 minutes

至:

},10); // cache for 10 minutes

不知道为什么......我找不到任何信息告诉我“真实”指的是什么(我从视频中复制了这段代码,几乎没有解释)。如果有人知道这意味着什么,请发表评论。

于 2014-12-19T21:51:43.910 回答