Glide库| 图片没有加载

Siz*_*ode 8 image laravel laravel-5 php-glide

我试图为我的localhost环境启用此库.

http://glide.thephpleague.com/1.0/config/integrations/laravel/

目前的Laravel版本 5.5

gd2 在wamp扩展中启用.

我似乎无法找到问题所在.

路径还可以,图片就在上面.

请参阅以下服务器配置代码.

$server = ServerFactory::create([
            'response' => new LaravelResponseFactory(app('request')),
            'source' => $source,
            //'cache' => new Filesystem(new Adapter('../storage/app/cache/')),
            'cache' => $cache,
            'cache_path_prefix' => '.cache',
            'base_url' => 'transform-img',
        ]);
Run Code Online (Sandbox Code Playgroud)

现在我用这个

return $server->getImageResponse($path, request()->all());
Run Code Online (Sandbox Code Playgroud)

它没有给出任何错误.

当我dd()这个,我得到这个回应.

StreamedResponse {#1151 ?
  #callback: Closure {#1177 ?}
  #streamed: false
  -headersSent: false
  +headers: ResponseHeaderBag {#1176 ?}
  #content: null
  #version: "1.0"
  #statusCode: 200
  #statusText: "OK"
  #charset: null
}
Run Code Online (Sandbox Code Playgroud)

回调关闭:

#callback: Closure {#1252 ?
    class: "League\Glide\Responses\SymfonyResponseFactory"
    this: LaravelResponseFactory {#1231 …}
    use: {?
      $stream: stream resource @543 ?
        timed_out: false
        blocked: true
        eof: false
        wrapper_type: "plainfile"
        stream_type: "STDIO"
        mode: "rb"
        unread_bytes: 0
        seekable: true
        uri: "D:\wamp\www\Bankrolla\storage\app/public\.cache/img/logo_no_text.png/32c8e67d979eab40a7ef6d1854f1f7cc"
        options: []
      }
    }
    file: "D:\wamp\www\Bankrolla\vendor\league\glide-symfony\src\Responses\SymfonyResponseFactory.php"
    line: "48 to 54"
  }
Run Code Online (Sandbox Code Playgroud)

正如statusCode显示200并且没有找到文件的错误,它仍然没有加载任何图像,但在我导航时在浏览器上显示占位符.

可能是什么问题.如果我尝试用任何其他随机字符串替换图像名称我得到错误的图像未找到.所以这意味着它确实找到了图像.你无法渲染图像.

我用谷歌搜索,搜索他们的github评论,找不到类似我的任何问题.

如果我直接加载它,我只会得到一个空白页面/图像.

在此输入图像描述

我也查看了缓存目录,它包含文件和那些文件尺寸调整大小.所以即使它生成缓存文件,我也不确定它出了什么问题.

在此输入图像描述

可能是我在这里缺少任何一点,如果有人能指出我正确的方向将是非常有帮助的.


更新:

价值$source变量:

Filesystem {#1225 ?
  #adapter: Local {#1226 ?
    #pathSeparator: "\"
    #permissionMap: array:2 [?
      "file" => array:2 [?
        "public" => 420
        "private" => 384
      ]
      "dir" => array:2 [?
        "public" => 493
        "private" => 448
      ]
    ]
    #writeFlags: 2
    -linkHandling: 2
    #pathPrefix: "D:\wamp\www\Bankrolla\storage\app/public\"
  }
  #plugins: []
  #config: Config {#1229 ?
    #settings: []
    #fallback: null
  }
}
Run Code Online (Sandbox Code Playgroud)

我的公共目录中的存储目录(它是原始存储的符号链接)

在此输入图像描述

Laravel的存储目录

在此输入图像描述

我正在调用此URL.

{localhostDomainHere}/image/img/logo_no_text.png?w=100&h=100&fit=crop-center

sya*_*yam 0

$source 提到的路径 => 将图像放在那里。如果是 1.jpg,则调用 url server_url/img/1.jpg 。img 来自您发布的相关功能的路线。在我的例子中,$source 和 $cache 是 /storage/app,我将图像放入其中并调用该图像上的路由。希望这对您有帮助。

检查这个

在此输入图像描述 这是我的代码:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Contracts\Filesystem\Filesystem;
use League\Glide\Responses\LaravelResponseFactory;
use League\Glide\ServerFactory;

class GlideController extends Controller
{
    public function show(Filesystem $filesystem, $path)
    {
        $server = ServerFactory::create([
            'response' => new LaravelResponseFactory(app('request')),
            'source' => $filesystem->getDriver(),
            'cache' => $filesystem->getDriver(),
            'cache_path_prefix' => '.cache',
            'base_url' => 'img',
        ]);

        return $server->getImageResponse($path, request()->all());
    }
}
Run Code Online (Sandbox Code Playgroud)

路线 :

Route::get('/img/{path}', 'GlideController@show')->where('path', '.*');
Run Code Online (Sandbox Code Playgroud)

这是我的存储/应用程序的内容

在此输入图像描述