RichEditor and Spatie Media Library

I'm using Spatie media library and it's filament plugin, i followed the instruction on setting up my model aso that i can use it with RichEditor TicketModel:
class Ticket extends Model implements HasMedia, HasRichContent
{
use HasFactory, InteractsWithMedia, InteractsWithRichContent;

public function registerMediaCollections(): void
{
$this->addMediaCollection('description');
}

public function setUpRichContent(): void
{
$this->registerRichContent('description')
->fileAttachmentProvider(SpatieMediaLibraryFileAttachmentProvider::make()
->preserveFilenames()
);
}
}
class Ticket extends Model implements HasMedia, HasRichContent
{
use HasFactory, InteractsWithMedia, InteractsWithRichContent;

public function registerMediaCollections(): void
{
$this->addMediaCollection('description');
}

public function setUpRichContent(): void
{
$this->registerRichContent('description')
->fileAttachmentProvider(SpatieMediaLibraryFileAttachmentProvider::make()
->preserveFilenames()
);
}
}
it works fine when i upload and save or edit but image doesn't appear on infolist view. my infolist textentry:
public static function make(): TextEntry
{
return TextEntry::make('description')

->state(fn ($record) => RichContentRenderer::make($record->description)
->toHtml()
)
->placeholder('-')
->icon(Heroicon::WrenchScrewdriver)
->iconColor('info')
->prose()
->columnSpanFull();
}
public static function make(): TextEntry
{
return TextEntry::make('description')

->state(fn ($record) => RichContentRenderer::make($record->description)
->toHtml()
)
->placeholder('-')
->icon(Heroicon::WrenchScrewdriver)
->iconColor('info')
->prose()
->columnSpanFull();
}
5 Replies
Hussain4real
Hussain4realOP2w ago
@awcodes any help here?
awcodes
awcodes2w ago
I believe the renderer also needs the file attachment provider
Hussain4real
Hussain4realOP7d ago
will give it a try
Hussain4real
Hussain4realOP5d ago
got this, when i tried
No description
awcodes
awcodes4d ago
Hmm, I would expect it to work.

Did you find this page helpful?