Skip to content

Commit d26d0d8

Browse files
author
taulantdisha
committed
feat: added console error when the file and image url are missing in the config options
1 parent 0b56cbb commit d26d0d8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/ngx-image-editor.component.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ export class NgxImageEditorComponent implements AfterViewInit, OnInit, OnDestroy
342342
public croppedImg: any;
343343

344344
@Input()
345-
public set configOption(options: EditorOptions) {
346-
this.state = options;
345+
public set config(config: EditorOptions) {
346+
this.state = config;
347347
}
348348

349349
@Output()
@@ -373,7 +373,7 @@ export class NgxImageEditorComponent implements AfterViewInit, OnInit, OnDestroy
373373
// NOTE if we don't have a file meaning that loading the image will happen synchronously we can safely
374374
// call initializeCropper in ngAfterViewInit. otherwise if we are using the FileReader to load a base64 image
375375
// we need to call onloadend asynchronously..
376-
if (!this.state.File) {
376+
if (!this.state.File && this.state.ImageUrl) {
377377
this.initializeCropper();
378378
}
379379
}
@@ -396,6 +396,15 @@ export class NgxImageEditorComponent implements AfterViewInit, OnInit, OnDestroy
396396
} else {
397397
this.ratios = NGX_DEFAULT_RATIOS;
398398
}
399+
400+
401+
if (!this.state.ImageUrl && !this.state.File) {
402+
console.error("Property ImageUrl or File is missing, Please provide an url or file in the config options.");
403+
}
404+
405+
if (!this.state.ImageName) {
406+
console.error("Property ImageName is missing, Please provide a name for the image.");
407+
}
399408
}
400409

401410
private convertFileToBase64(file: File) {

0 commit comments

Comments
 (0)