for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Encore\Admin\Grid\Displayers;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Facades\Storage;
class Image extends AbstractDisplayer
{
public function display($server = '', $width = 200, $height = 200)
if ($this->value instanceof Arrayable) {
$this->value = $this->value->toArray();
}
return collect((array) $this->value)->filter()->map(function ($path) use ($server, $width, $height) {
if (url()->isValidUrl($path)) {
$src = $path;
} elseif ($server) {
$src = rtrim($server, '/').'/'.ltrim($path, '/');
} else {
$src = Storage::disk(config('admin.upload.disk'))->url($path);
return "<img src='$src' style='max-width:{$width}px;max-height:{$height}px' class='img img-thumbnail' />";
})->implode(' ');