Fields

Image

Inherits File.

  • has the same capabilities

The Image field is an extension of File that allows previewing uploaded images.

use MoonShine\UI\Fields\Image;Image::make('Thumbnail')
use MoonShine\UI\Fields\Image;
 
Image::make('Thumbnail')
<x-moonshine::form.file
:imageable="true"
name="thumbnail"
/>

image

image dark

If you need to customize a modal window with an image in preview mode, then you can use the extraAttributes() method:

Image::make('avatar') ->extraAttributes(fn(string $filename, int $index): ?FileItemExtra => new FileItemExtra(wide: false, auto: true, styles: 'width: 250px;')),
Image::make('avatar')
->extraAttributes(fn(string $filename, int $index): ?FileItemExtra => new FileItemExtra(wide: false, auto: true, styles: 'width: 250px;')),
  • wide - XL size of the modal window,
  • auto - The window size will adjust to the size of the content,
  • styles - Additional styles for the image in the modal window.