Mawi137 / ngx-image-cropper

An image cropper for Angular
MIT License
786 stars 210 forks source link

Error on Angular 17+ #633

Closed adi-wtag closed 6 months ago

adi-wtag commented 6 months ago

I am having two errors

ERROR ReferenceError: Image is not defined
ERROR ReferenceError: window is not defined
ERROR ReferenceError: FileList is not defined
    at _ImageCropperComponent.isValidImageChangedEvent (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/ngx-image-cropper/fesm2022/ngx-image-cropper.mjs:1169:29)
    at _ImageCropperComponent.onChangesInputImage (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/ngx-image-cropper/fesm2022/ngx-image-cropper.mjs:1154:46)
    at _ImageCropperComponent.ngOnChanges (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/ngx-image-cropper/fesm2022/ngx-image-cropper.mjs:1109:10)
    at _ImageCropperComponent.rememberChangeHistoryAndInvokeOnChangesHook (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/@angular/core/fesm2022/core.mjs:4101:14)
    at callHookInternal (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/@angular/core/fesm2022/core.mjs:5136:14)
    at callHook (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/@angular/core/fesm2022/core.mjs:5167:9)
    at callHooks (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/@angular/core/fesm2022/core.mjs:5118:17)
    at executeInitAndCheckHooks (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/@angular/core/fesm2022/core.mjs:5068:9)
    at selectIndexInternal (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/@angular/core/fesm2022/core.mjs:11029:17)
    at Module.ɵɵadvance (/Users/arafat.dipto/Desktop/cora/pidas-cora/CORA-FRONTEND/src/frontend/node_modules/@angular/core/fesm2022/core.mjs:11012:5)

Is it because of SSR ? How to fix this one ?

Mawi137 commented 6 months ago

Hi, yes it's because of SSR. You should probably not render the image cropper on the server side. I have no experience with SSR so I'm not sure if this could be integrated into the cropper itself.

adi-wtag commented 6 months ago

Thanks for confirming. But the functionality I require is working properly even though it's throwing these errors. Anyway, I am getting rid of SSR. So, it should be fine.