Image
You're browsing the documentation for an old version of MoonShine. Consider upgrading your project to MoonShine 2.x.
Extends
File
* has the same features
Everything is the same as File
, only the display changes
use MoonShine\Fields\Image; //...public function fields(): array{ return [ //... Image::make('Thumbnail', 'thumbnail') ->dir('/') // The directory where the files will be stored in storage (by default /) ->disk('public') // Filesystems disk ->allowedExtensions(['jpg', 'gif', 'png']) // Allowable extensions //... ];}//...
To correctly generate the file URL, you must define the environment variable APP_URL
in this way,
to match your app's URL.
When using the local
driver, the return value of url
is not URL encoded.
For this reason, we recommend always storing your files using names that will create valid URLs.