1

I recently updated some of the photos for a user group. I'm using the default user photo field.

I'm displaying the user photos on the front-end of my site and the images were displaying just fine. After replacing the images the image tag on the front-end of my site is showing a broken image. If I view the image tag src it points to the old image filename, not the updated file's filename.

I have cleared Craft's cache.

How I can make getPhotoUrl() use the new filename?

  • Did you clear all caches? Specifically, if the photo is in {% cache %} tags, you'll need to clear the template caches. – Brad Bell Jan 28 '15 at 21:33
  • I have cleared all caches via the Clear Caches tool. – Brett DeWoody Jan 28 '15 at 21:37
  • Just tried a test locally and I'm not able to reproduce. The profile image updated successfully. In the craft_users table what's the value of the photo column for the user? – Brad Bell Jan 29 '15 at 2:20
  • The image in the CP updates to the new image. But the image on the front-end still points to the old image filename. – Brett DeWoody Feb 3 '15 at 19:28
1

Can I ask why you can't change the filename to the old one? For the new file that is. That will easily solve the problem.

The reason it won't show up as per the new file name is that when you upload a profile photo for a user, craft creates a image model for it and when copying over a file directly this image model will not be created hence you either need to use the backend for uploading profile photos or change the filename to the old one. Also you would need to do this in multiple folders as inside userphotos/{username}/ you will see that there are multiple folders, these are folders for different cropped sizes of the profile photo and will be displayed in different locations, Hence you will need to replace the file in all of these locations for the user photo to appear correctly in all places.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.