Action for PDF and JPG preview

Hi, I need to create a preview action to display a preview of PDF and JPG files in a modal. How should I proceed, is there something ready in Filament? Thanks.
Solution:
Remove ->requiresConfirmation(false) and try again
Jump to solution
12 Replies
joao nivaldo
joao nivaldoOP10mo ago
It worked, thank you. But I can't make the modal's width as wide as possible. I've already tried several possible values within MaxWith::FourExtraLarge, Full, LG, SM and others and it only stays at this width. I've already given npm run build several times. Is there anything to be done?
No description
Tim van Heugten
Tim van Heugten10mo ago
Show your action code (modalWidth). In your message you write MaxWith but I assume your code has MaxWidth?
joao nivaldo
joao nivaldoOP10mo ago
No description
joao nivaldo
joao nivaldoOP10mo ago
That's right. Any value I put in the modalWidth method will always be the same size. I've already run npm run builder several times and it's still the same.
Solution
Tim van Heugten
Tim van Heugten10mo ago
Remove ->requiresConfirmation(false) and try again
Tim van Heugten
Tim van Heugten10mo ago
You use it (->requiresConfirmation()) when you have an action defined that you only want to run after a confirmation is given. In your case it is not applicable (and you wouldn't set it to false but just omit it). Apparently when you do use it a default width is applied (not sure if that is a bug or intended behavior).
JJ
JJ10mo ago
url is error
No description
JJ
JJ10mo ago
Argument #1 ($record) must be of type Blueprint\Contracts\Model
Tim van Heugten
Tim van Heugten10mo ago
Not sure how we got here after the discussion about the modal width. Anyway this errors means you are using the wrong Model class in the function. This should be Eloquent’s model class, not the contract class (so the Model in the fn(Model $record) is the wrong class).
JJ
JJ10mo ago
what should I do Sir? Do you have any sample code to view the uploaded PDF file? Because this is the of my problem to my project. Hope your quick response. Thank you Sir. God bless.
Tim van Heugten
Tim van Heugten10mo ago
At the top of your file replace use Blueprint\Contracts\Model; with use Illuminate\Database\Eloquent\Model; But next time post a new #❓┊help question as your question is completely unrelated to OP's question.
Want results from more Discord servers?
Add your server