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

How to get compressed/resized image? #22

Closed
weiliank opened this issue Apr 4, 2018 · 6 comments
Closed

How to get compressed/resized image? #22

weiliank opened this issue Apr 4, 2018 · 6 comments

Comments

@weiliank
Copy link

weiliank commented Apr 4, 2018

How to get the result of image after uploading process?

I tried the codes below:

$('.filepond').on('FilePond:processfile', function(e) {
            if (e.detail.error) {
                console.log('Oh no');
                return;
            }
            console.log('File processed', e.detail.file);
        });

but when i inspect back the image size or dimension is still the same as original file.

@rikschennink
Copy link
Collaborator

@weiliank Have you added the image-transform plugin?

@weiliank
Copy link
Author

weiliank commented Apr 4, 2018

Hi @rikschennink

Yes, I did included the plugin library and also I have registered the plugin

FilePond.registerPlugin(
            // encodes the file as base64 data
            FilePondPluginFileEncode,
            // validates the size of the file
            FilePondPluginFileValidateSize,
            // corrects mobile image orientation
            FilePondPluginImageExifOrientation,
            // previews dropped images
            FilePondPluginImagePreview,
            FilePondPluginFileValidateType,
            FilePondPluginImageTransform
        );

I am wondering how to get the compressed/resized image upload to the server (localhost/cloud).

Thanks!

@rikschennink
Copy link
Collaborator

@weiliank If you're uploading using XMLHttpRequest ( the server config property ) you can leave out the File Encode plugin. How have you configured the server property?

@weiliank
Copy link
Author

weiliank commented Apr 4, 2018

Hi @rikschennink,

I configured it as below:

const inputElement = document.querySelector('.filepond');
        const pond = FilePond.create(inputElement, {
            labelIdle: 'Drag & Drop your picture or <span class="filepond--label-action">Browse Your PC</span>',
            imagePreviewHeight: 400,
            imageCropAspectRatio: '1:1',
            imageResizeTargetWidth: 300,
            imageResizeTargetHeight: 300,
            imageResizeMode: 'cover',
            instantUpload: true,
            allowFileEncode: true,
            allowImageTransform: true,
            server: {
                url: '<?php echo base_url()?>', // http://localhost/wine/
                timeout: 7000,
                process: {
                    url: 'products/azure',
                    method: 'POST'
                }
            }
        });

Is this correct?

@rikschennink
Copy link
Collaborator

rikschennink commented Apr 4, 2018

@weiliank Looks okay to me. You can remove these lines allowFileEncode: true and allowImageTransform: true as plugins are enabled by default. It looks okay otherwise.

Just took a look at the registerPlugin snippet for the second time, it seems the Image Crop and Image Resize plugins are not loaded.

@rikschennink
Copy link
Collaborator

@weiliank Will close for now as the issue is probably related to the Image Crop and Image Resize plugins not being loaded.

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

No branches or pull requests

2 participants