Laravel Statamic 应用程序未实时加载图像,在本地主机上运行良好。已尝试过存储:链接和所有其他解决方案

问题描述 投票:0回答:1

如前所述,数字海洋应用程序平台上的 Laravel Statamic 应用程序中我的图像的 src 无法通过。替代文本就在那里。这些图像在本地工作得非常好,我认为这是一个常见问题,我已经尝试了所有修复,但没有一个对我有用。

  • 确保我所有的资产盘都有url并且是公开的

  • 已完成存储:链接

  • 已使用用户 ini 增加了 php 内存限制 - 并验证其有效

  • 为 Digital Ocean 中的 url、应用程序密钥等设置环境变量

  • 老实说,我还没有尝试删除公共存储文件夹,我不知道如何通过控制台实时执行此操作

我确实认为这是下面文件中的符号链接的问题,但我无法弄清楚它出了什么问题。我确信这很简单,但我正在用头撞墙来解决这个问题。

非常欢迎任何建议!谢谢!

文件系统.php:

返回[

/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/

'default' => env('FILESYSTEM_DISK', 'images'),

'cloud' => env('FILESYSTEM_CLOUD', 's3'),

/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been set up for each driver as an example of the required values.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app'),
        'throw' => false,
        'url' => '/images',
        'visibility' => 'public',
    ],

    'public' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'url' => env('APP_URL') . '/storage',
        'visibility' => 'public',
        'throw' => false,
    ],

    's3' => [
        'driver' => 's3',
        'key' => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'region' => env('AWS_DEFAULT_REGION'),
        'bucket' => env('AWS_BUCKET'),
        'url' => env('AWS_URL'),
        'endpoint' => env('AWS_ENDPOINT'),
        'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
        'throw' => false,
    ],

    'images' => [
        'driver' => 'local',
        'root' => public_path('images'),
        'url' => '/images',
        'visibility' => 'public',
    ],

    'favicons' => [
        'driver' => 'local',
        'root' => public_path('favicons'),
        'url' => '/favicons',
        'visibility' => 'public',
    ],

    'files' => [
        'driver' => 'local',
        'root' => public_path('files'),
        'url' => '/files',
        'visibility' => 'public',
    ],

    'social_images' => [
        'driver' => 'local',
        'root' => public_path('social_images'),
        'url' => '/social_images',
        'visibility' => 'public',
    ],

],

/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/

'links' => [
    public_path('storage') => storage_path('app/public'),
],

];

php laravel digital-ocean statamic
1个回答
0
投票

可能的检查:

  1. 检查文件权限:您可以查看这里

2.验证存储链接: 确保从 public/storage 到 storage/app/public 的符号链接存在。您可以通过运行以下命令来检查这一点:

ls -l public

  1. 检查模板中的图像 URL: 确保静态模板中的图像 URL 正确。您可以使用 asset tag 或 Laravel 的 asset helper 函数。

    <img src="{{ asset('images/your-image.jpg') }}" alt="Alt text">

  2. 磁盘配置中的资产 URL: 在 filesystems.php 配置中,更新“images”磁盘的 url 以使用正确的 URL:

    “图像”=> [ '司机' => '本地', '根' => public_path('图像'), 'url' => env('APP_URL') 。 '/图片', '可见性' => '公开', ],

  3. 清除配置缓存:

    php artisan config:clear

© www.soinside.com 2019 - 2024. All rights reserved.