简体   繁体   中英

How to set custom url for loading images on page

I have set this path for loading images:

<img src="{{\Illuminate\Support\Facades\Storage::url($newest->uploaded->where('upf_uploaded_as', 'feature_image')->where('upf_dimension', '200x200')->first()->upf_path)}}" class="card-img-top" alt="">

And this is basically going to the URL of the current website domain and open up storage/upload/1399/10/images/{imagename} .

But now, I need to specify another URL as a domain. So instead of this:

http://currentwebsite.com/storage/upload/1399/10/images/PCVS511-5 (1).jpg

This will load the images:

http://differentwebsite.com/storage/upload/1399/10/images/PCVS511-5 (1).jpg

So the path that calls storage/upload/1399/10/images/{imagename} is the same. The domain name is just different. But I don't know how to give my custom URL to this.

So if you know, please help me out with this, cause I really need it.

Thanks.

You can create another drive for the storage (found in config/filesystems.php ), which has the same configuration as the original, but has a different setting for the url option:

'other_public' => [
    'driver' => 'local',
    'root' => storage_path('app/public'),
    'url' => 'http://differentwebsite.com/storage',
    'visibility' => 'public',
],

Documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM