What you are trying to do is not possible in the repository directory, but only in the public directory, and identifying the path or URL of your laravel storage directory creates some vulnerability and its bad practice.
However, there is a way around this:
First, you need the Image package to dynamically create an image when a specific route is referenced, I recommend tampering / image , which has many methods that make the image wind-driven.
To do this, follow these steps:
1. Set the image of the intervention:
Add an intervention image to your .json composer and do a composer update
"require": { "php": ">=5.5.9", "laravel/framework": "5.1.*", "intervention/image": "2.*", "intervention/imagecache": "2.*" .....
In the $ providers array, add the service providers for this package.
'Intervention\Image\ImageServiceProvider'
Add the facade of this package to the $ aliases array.
'Image' => 'Intervention\Image\Facades\Image '
Customize Laravel 5 intervention image
$ php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"
Publish configuration in Laravel 4
$ php artisan config:publish intervention/image
Learn more about setting https://github.com/Intervention/image
After setting the intervention / image, you can do something like this:
Image::make($path=storage_path('stock-photos/image1.jpg'));
2. Setting the route that will handle image requests
Route::get('stock-photos/{image}', function($image){ //do so other checks here if you wish if(!File::exists( $image=storage_path("stock-photos/{$image}") )) abort(404); return Image::make($image)->response('jpg'); //will ensure a jpg is always returned });
3. Then in the view, you can do the following:
@foreach($projects as $project) <li> <img src="{{url('stock-photos/'. $project->fetchMedia->first()->public_name)}}" title="{{$project->name}}"> </li> @endforeach