Introduction
Infolists can render images, based on the path in the state of the entry:header_image state could contain posts/header-images/4281246003439.jpg, which is relative to the root directory of the storage disk. The storage disk is defined in the configuration file, local by default. You can also set the FILESYSTEM_DISK environment variable to change this.
Alternatively, the state could contain an absolute URL to an image, such as https://example.com/images/header.jpg.
Managing the image disk
The default storage disk is defined in the configuration file,local by default. You can also set the FILESYSTEM_DISK environment variable to change this. If you want to deviate from the default disk, you may pass a custom disk name to the disk() method:
Public images
By default, Filament will generate temporary URLs to images in the filesystem, unless the disk is set topublic. If your images are stored in a public disk, you can set the visibility() to public:
Customizing the size
You may customize the image size by passing aimageWidth() and imageHeight(), or both with imageSize():
Square images
You may display the image using a 1:1 aspect ratio:Circular images
You may make the image fully rounded, which is useful for rendering avatars:Adding a default image URL
You can display a placeholder image if one doesn’t exist yet, by passing a URL to thedefaultImageUrl() method:
Stacking images
You may display multiple images as a stack of overlapping images by usingstacked():
Customizing the stacked ring width
The default ring width is3, but you may customize it to be from 0 to 8:
Customizing the stacked overlap
The default overlap is4, but you may customize it to be from 0 to 8:
Setting a limit
You may limit the maximum number of images you want to display by passinglimit():
Showing the remaining images count
When you set a limit you may also display the count of remaining images by passinglimitedRemainingText().
Customizing the limited remaining text size
By default, the size of the remaining text isTextSize::Small. You can customize this to be TextSize::ExtraSmall, TextSize::Medium or TextSize::Large using the size parameter:
Prevent file existence checks
When the schema is loaded, it will automatically detect whether the images exist to prevent errors for missing files. This is all done on the backend. When using remote storage with many images, this can be time-consuming. You can use thecheckFileExistence(false) method to disable this feature:
Adding extra HTML attributes to the image
You can pass extra HTML attributes to the<img> element via the extraImgAttributes() method. The attributes should be represented by an array, where the key is the attribute name and the value is the attribute value:
extraImgAttributes() multiple times will overwrite the previous attributes. If you wish to merge the attributes instead, you can pass merge: true to the method.