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

Replace image failed with exception "this.image is undefined" #396

Closed
Int32Overflow opened this issue Feb 19, 2025 · 1 comment
Closed
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@Int32Overflow
Copy link

Describe the bug
I like to replace the current image with a new version of the image. The first replace is working, but the second replace failed with following error message:

this.image is undefined
replace@http://localhost:5165/_content/Cropper.Blazor/cropper.min.js:10:22878
replace@http://localhost:5165/_content/Cropper.Blazor/cropperJsInterop.min.js:1:1746
beginInvokeJSFromDotNet/s<@http://localhost:5165/_framework/blazor.server.js:1:3047
beginInvokeJSFromDotNet@http://localhost:5165/_framework/blazor.server.js:1:3004
_invokeClientMethod@http://localhost:5165/_framework/blazor.server.js:1:60890
_processIncomingData@http://localhost:5165/_framework/blazor.server.js:1:58279
Xt/this.connection.onreceive@http://localhost:5165/_framework/blazor.server.js:1:51920
connect/</s.onmessage@http://localhost:5165/_framework/blazor.server.js:1:80026

I would like to keep the current status (rotation, cropping) when updating the image.

The code snippet:

try
{
    isLoadingImage = true;
    await InvokeAsync(StateHasChanged);
    var oldImageSource = this.imageSource;
    this.imageSource = GetImageSource();
    await cropperComponent.ReplaceAsync(this.imageSource);
    await cropperComponent.RevokeObjectUrlAsync(oldImageSource);
}
catch (Exception ex)
{
    throw;
}
finally
{
    isLoadingImage = false;
    await InvokeAsync(StateHasChanged);
}

To Reproduce
Steps to reproduce the behavior:

  1. Call method ReplaceAsync
  • The first time every think is okay
  1. Call method ReplaceAsync again
  • See error
@Int32Overflow
Copy link
Author

I solved the problem with the help of this post #150

@MaxymGorn MaxymGorn self-assigned this Feb 20, 2025
@MaxymGorn MaxymGorn added the documentation Improvements or additions to documentation label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants