php - Voyager doesn't show images because of exists() function


I have a blog project created using Laravel, It works fine on my localhost, I uploaded the project and converted it to work on a shared host, and this is not my first time doing this, after uploading the project and the database, Everything works fine, I mean when opening the blog I can see my posts (WITH PICTURES) and categories and everything, BUT in the Voyager CPanel I can't see images, so I picked the admin logo as an example, In the database it contains this name (settings/January2018/PnrVRpff94865gfxeZ0gt.png) and the Voyager sideBar Blade code for this image is this :

<?php $admin_logo_img = Voyager::setting('admin_icon_image', ''); ?>
@if($admin_logo_img == '')
    <img src="{{ voyager_asset('images/logo-icon-light.png') }}" alt="Logo Icon">
    <img src="{{ Voyager::image($admin_logo_img) }}" alt="Logo Icon">

and the result on chrome is this :

<img src="" alt="Logo Icon">

So I went to theVoyager::image() function :

public function image($file, $default = '')
        if (!empty($file) && Storage::disk(config(''))->exists($file)) {
            return Storage::disk(config(''))->url($file);

        return $default;

And I did my tests and here is the results in this logo case :

empty($file) Return False (Good)

Storage::disk(config(''))->exists($file) Return False (Bad)

Storage::disk(config(''))->url($file) Return the Correct URL (Good)

Knowing thatconfig('') Return "public" and the filesystems disks config is untouched.

As you see the problem in theVoyager::image() Function, So please help me solve this problem in the right way.

Update :

I tried changing the Voyager::image() function in the /vendor/tcg/voyager/src folder To :

public function image($file, $default = '')
        //Bad Solution
        return Storage::disk(config(''))->url($file);

and it worked so well, but as you see it's a bad solution, And I need a right one, So please help.

People are also looking for solutions to the problem: php - Use custom normalizer to modify class properties


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.