open-admin icon indicating copy to clipboard operation
open-admin copied to clipboard

Image field URL prefix duplicate

Open malikghanim opened this issue 1 year ago • 6 comments

I installed open-admin by following the instructions step by step, Then I updated the config/filesystems.php and added the following :

'admin' => [
            'driver' => 'local',
            'root' => public_path('uploads'),
            'visibility' => 'public',
            'url' => env('APP_URL').'/uploads',
        ],

I update user record from admin http://localhost/admin/auth/users/1/edit and upload new avatar image

The Image is not showing, when I inspect the image I found that image url prefix duplicated as following http://localhost/uploads/http://localhost/uploads/images/User_icon-cp.png

How to resolve that issue?

malikghanim avatar Nov 26 '23 04:11 malikghanim

I have this same problem, have you found any solution for this?

Tech-Loyal avatar Jan 10 '24 18:01 Tech-Loyal

Same problem here, also need a solution to this. Showing when inspecting: http://localhost/uploads/http://localhost/uploads/images/image.png

In admin.php file: 'upload' => [

    // Disk in `config/filesystem.php`.
    'disk' => 'admin',

    // Image and file upload path under the disk above.
    'directory' => [
        'image' => 'images',
        'file'  => 'files',
    ],
],

In filesystems.php file: 'disks' => [

    'admin' => [
        'driver' => 'local',
        'root' => public_path('uploads'),
        'url' => env('APP_URL').'/uploads',
        'visibility' => 'public',
    ],
    ...
    ..

AndreasMySch avatar Feb 20 '24 07:02 AndreasMySch

I have this same problem, have you found any solution for this?

subrata6630 avatar Mar 30 '24 16:03 subrata6630

anyone?

drlafo avatar Apr 05 '24 13:04 drlafo

The problem occurs because the images path are saved with full path in the database. I solved this problem changing the 'upload' default disk to 'public' in config/admin.php file:

'upload' => [

        // Disk in config/filesystem.php.
        'disk' => 'public',

        // Image and file upload path under the disk above.
        'directory' => [
            'image' => 'images',
            'file'  => 'files',
        ],
    ],

In config/filesystem.php I setted the public path this way:

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

This way the path is relative. This configuration worked for both localhost and live servers.

I implement this way in my Blade templates.

<img src="{{ asset('storage') . '/' . $image }}">

zapsys avatar May 28 '24 03:05 zapsys