0

Currently I'm showing an image with the following code:

<img ng-src="{{user.profileImage}}") class='img-circle photo' />

The user is able to change that photo using an upload function. The profileImage will be overwritten because filename is renamed to the users _id. So for example the path is: https://some-bucket.s3.amazonaws.com/profiles/5cfa5fb5850b2755d89574cc.png.

After a successful upload the path stays the same, but the content on the url will become different, the image will still show the old image, even after reloading the whole $scope.user.

I tried to use an different path for the image like data.profileImage and clearing user.profileImage before loading, adding ng-if="user.profileImage !='' to the image, but it isn't working.

Is there a way to reload the image without reloading the whole page?

I didn't paste the upload code, I think it's not necessary for this issue.

2
  • 1
    Sounds like a caching issue. Try appending ?<timestamp> to user.profileImage Commented Sep 12, 2019 at 13:55
  • @user2954463 ow yeah. Please post that as an answer, so I can mark it as the solution. Commented Sep 12, 2019 at 14:03

1 Answer 1

2

I think this is a browser caching issue, not ng-src problem.

Try appending ?<timestamp> to value of user.profileImage.

This will force browser to fetch the new image.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.