
Announcements
I have a photo outside the gallery that displays the user's current photo or his initials if he does not have a profile photo (I use an external website UI AVATARS).
Everything works fine and the code looks like this:
If(
IsBlank(UżytkownicyusługiOffice365.UserPhotoV2(User().Email));
"https://ui-avatars.com/api/?name=" & Left(User().FullName; 1) & "+" & Mid(User().FullName; Find(" "; User().FullName) + 1; 1) & "&background=0075D4&color=FFFFFF";
UżytkownicyusługiOffice365.UserPhotoV2(User().Email)
)
I have a problem with a similar setting but in the gallery. I want to set it to display photos of the author of the entry from the SharePoint list, and if the author does not have a photo, display his initials.
The code looks like this but if someone does not have a profile photo, the initials are only shown for a second after refreshing the gallery and the image disappears.
If(
!IsBlank(ThisItem.Author.Email);
UżytkownicyusługiOffice365.UserPhotoV2(ThisItem.Author.Email);
"https://ui-avatars.com/api/?name=" & Left(ThisItem.Author.DisplayName; 1) & "+" & Mid(ThisItem.Author.DisplayName; Find(" "; ThisItem.Author.DisplayName) + 1; 1) & "&background=FFFFFF&color=0075D4"
)
I also tried to use an uploaded photo ("TESTIMAGE") to display it if someone does not have a profile photo. But there is the same problem. If someone has a profile photo, it is displayed, but if they don't, a replacement photo appears for a second after refreshing the gallery and disappears.
The code looks like this:
If(
!IsBlank(ThisItem.Author.Email);
UżytkownicyusługiOffice365.UserPhotoV2(ThisItem.Author.Email);
TESTIMAGE
)
And this code has the same problem:
If(
!IsBlank(ThisItem.Author.Email);
If(
IsBlank(UżytkownicyusługiOffice365.UserPhotoV2(ThisItem.Author.Email));
TESTIMAGE;
UżytkownicyusługiOffice365.UserPhotoV2(ThisItem.Author.Email)
);
TESTIMAGE
)
Unfortunately, my knowledge ends here and I don't know how to solve this problem to display it in one photo control.
Use Default Property: Set the default property of the Image control in your gallery to the placeholder image or initials. This ensures that there's always a default image displayed, and it won't flicker when loading the actual image.
Preload Images: You can try preloading the images in advance to reduce flickering. One way to do this is by using a collection to store the images before displaying them in the gallery.
Then, in your gallery, use LookUp to retrieve the image from the collection.
Set Image Visibility: You can use the Visible property to control the visibility of the image based on whether it's blank or not.
This way, the image control won't even be visible if there's no photo.
Try implementing these suggestions and see if they help in resolving the flickering issue. Let me know how it goes!