CTOlet / yii2-attachments

Yii2 extension for uploading and attaching the files to the models
66 stars 57 forks source link

Allow file controller do download inline and adjust preview configs #88

Closed dmkdesign closed 10 months ago

dmkdesign commented 10 months ago

When getting file urls, we can't use them in previews since they directly download in the file controller. We have to wrap them in img tags for images, or a fake container with a file image for other types. If we allow the user the option of downloading inline, $file->getUrl('inline'=true) we can use the function to generate urls that are compatible with Kartiks File Input option 'initialPreviewAsData'=> 'true',

This means that the file input widget can create the preview code automatically by setting the "type" parameter based on the file mime type in initialPreviewConfig.

This pull request adds an optional parameter to getUrl, and handles that in the filecontroller.

It also updates the built in AttachmentsInput to generate the attachments input with better previewConfigs (image, pdf, txt, office, video)