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

allow changing cropped image mime type #762

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wing5wong
Copy link

@wing5wong wing5wong commented Jan 19, 2025

Hi there

Id like to be able to crop images using the image upload as described here: https://mary-ui.com/docs/components/file#image-crop

with the current setup, i believe this always generates image/png versions of the image by default. I would like to be able to generate image/jpeg versions,

The cropperjs docs indicate we can change the mime type here - im not sure how you would want to approach the custom choice here in the File component. (https://github.com/fengyuanchen/cropperjs/blob/main/README.md#getcroppedcanvasoptions)

this.cropper.getCroppedCanvas().toBlob((blob) => {
                                blob.name = $refs.file.files[0].name
                                @this.upload('{{ $attributes->wire('model')->value }}', blob,
                                    (uploadedFilename) => {  },
                                    (error) => {  },
                                    (event) => { this.progress = event.detail.progress }
                                )
                            }, 'image/jpeg')

with this change, the user can set the mime type as follows
<x-file wire:model="photo" accept="image/png" crop-after-change cropMimeType="image/jpeg">

resolves #761

the user can set the mime type as such
<x-file wire:model="photo" accept="image/png" crop-after-change cropMimeType="image/jpeg">
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 this pull request may close these issues.

Add option to define mime type when cropping image
1 participant