Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acceptedFileTypes should not let you pick another file type #157

Closed
lotarbo opened this issue Apr 4, 2023 · 5 comments · Fixed by #158
Closed

acceptedFileTypes should not let you pick another file type #157

lotarbo opened this issue Apr 4, 2023 · 5 comments · Fixed by #158

Comments

@lotarbo
Copy link
Contributor

lotarbo commented Apr 4, 2023

I have field with acceptedFileTypes(['image/jpeg', 'image/png']) and I can't upload any other file type, but I can pick any file from already uploaded. I can pick mp4 video for this field.

@lotarbo lotarbo changed the title acceptedFileTypes should not let you choose another type acceptedFileTypes should not let you pick another file type Apr 4, 2023
@alanablett
Copy link

alanablett commented Sep 8, 2023

Hi @awcodes I'm not sure if this one is totally fixed? I Was still able to select previously uploaded files when using the acceptedFilesTypes argument on my CuratorPicker field.

I was taking a look through the code for the curator panel component and saw that the getFiles method actually uses a property called types to check for file types. So I went ahead and created an override of vendor/awcodes/filament-curator/resources/views/components/actions/picker-action.blade.php locally and passed through the acceptedFilesTypes but passed them through to the types property. This seems to work as expected. However I didnt know if there was a specific reason you'd done it in the way you have. My picker-action.blade.php looks like this

<livewire:curator-panel
    :accepted-file-types="$acceptedFileTypes"
    :types="$acceptedFileTypes" // copy of the acceptedFileTypes
    :disk-name="$diskName"
    :directory="$directory"
    :image-crop-aspect-ratio="$imageCropAspectRatio"
    :image-resize-mode="$imageResizeMode"
    :image-resize-target-width="$imageResizeTargetWidth"
    :image-resize-target-height="$imageResizeTargetHeight"
    :is-limited-to-directory="$isLimitedToDirectory"
    :is-multiple="$isMultiple"
    :max-items="$maxItems"
    :max-width="$maxWidth"
    :min-size="$minSize"
    :max-size="$maxSize"
    :modal-id="$modalId"
    :path-generator="$pathGenerator"
    :rules="$rules"
    :selected="$selected ?? []"
    :should-preserve-filenames="$shouldPreserveFilenames"
    :state-path="$statePath"
    :visibility="$visibility"
/>

@awcodes
Copy link
Owner

awcodes commented Sep 8, 2023

Are you on v2 or v3 of the plug-in? It does work on v2. Unless I'm misunderstanding what issue you're having.

@alanablett
Copy link

Are you on v2 or v3 of the plug-in? It does work on v2. Unless I'm misunderstanding what issue you're having.

I'm using awcodes/filament-curator:3.0.0 and filament/filament:3.0.41

I just went ahead and created a test project using awcodes/filament-curator:2.10.1 and filament/filament:2.17.53 and can confirm that the acceptedFileTypes array does work as expected. The list of available files is filtered down to just the types that I specify on the field. So it looks like a v3 specific issue.

@awcodes
Copy link
Owner

awcodes commented Sep 9, 2023

Ok. I'll get it corrected as soon as I can. Thank you.

@alanablett
Copy link

Ok. I'll get it corrected as soon as I can. Thank you.

Thank you so much for the awesome plugin 👏👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants