фикс фото в ленте
This commit is contained in:
parent
0281ba1054
commit
e458c8e137
@ -34,7 +34,7 @@
|
||||
<img :src="photo.url"
|
||||
class="d-block w-100 user-photo"
|
||||
:alt="'Фото ' + currentUserToSwipe.name + ' ' + (index + 1)"
|
||||
@error="onImageError($event, currentUserToSwipe, photo._id)">
|
||||
@error="onImageError($event, currentUserToSwipe, photo)"> <!-- MODIFIED: pass photo object -->
|
||||
</div>
|
||||
</div>
|
||||
<button v-if="currentUserToSwipe.photos.length > 1" class="carousel-control-prev" type="button" :data-bs-target="`#carouselUserPhotos-${currentUserToSwipe._id}`" data-bs-slide="prev">
|
||||
@ -222,25 +222,33 @@ const formatGender = (gender) => {
|
||||
return ''; // Возвращаем пустую строку, если пол не указан, чтобы не было "Пол не указан"
|
||||
};
|
||||
|
||||
const onImageError = (event, userOnError, photoIdOnError) => {
|
||||
console.warn("Не удалось загрузить изображение:", event.target.src, "для пользователя:", userOnError.name, "фото ID:", photoIdOnError);
|
||||
const userInSuggestions = suggestions.value.find(u => u._id === userOnError._id);
|
||||
if (userInSuggestions && userInSuggestions.photos) {
|
||||
const photoIndex = userInSuggestions.photos.findIndex(p => p._id === photoIdOnError);
|
||||
if (photoIndex > -1) {
|
||||
// Вместо удаления можно установить флаг ошибки или заменить URL на заглушку
|
||||
// userInSuggestions.photos.splice(photoIndex, 1);
|
||||
// Если просто убрать фото из массива, и оно было единственным, карусель исчезнет.
|
||||
// Лучше обработать это в UI, показав заглушку для этого конкретного слайда или скрыв слайд.
|
||||
// Пока просто выводим ошибку и позволяем Bootstrap обработать битую картинку (покажет alt текст).
|
||||
event.target.style.display = 'none'; // Скрываем битое изображение
|
||||
// Можно добавить заглушку на место битого изображения, если это один слайд из многих
|
||||
const onImageError = (event, userOnError, photoWithError) => { // MODIFIED: signature and content
|
||||
console.warn(
|
||||
"SwipeView: Не удалось загрузить изображение.",
|
||||
{
|
||||
src: event.target.src,
|
||||
user: userOnError.name,
|
||||
photo_id: photoWithError._id,
|
||||
photo_url: photoWithError.url,
|
||||
event_target_attributes: {
|
||||
naturalWidth: event.target.naturalWidth,
|
||||
naturalHeight: event.target.naturalHeight,
|
||||
complete: event.target.complete,
|
||||
},
|
||||
errorEventDetails: event
|
||||
}
|
||||
// Если после ошибки не осталось фото, показываем общую заглушку
|
||||
if (!userInSuggestions.photos.some(p => p.url)) {
|
||||
userInSuggestions.mainPhotoUrl = null; // Это для старой логики с одним фото, нужно будет обновить
|
||||
}
|
||||
}
|
||||
);
|
||||
// For debugging, let's NOT hide the image for now.
|
||||
// This will show the browser's default broken image icon.
|
||||
// event.target.style.display = 'none'; // MODIFIED: Commented out for debugging
|
||||
|
||||
// The logic to update userInSuggestions.mainPhotoUrl is outdated.
|
||||
// const userInSuggestions = suggestions.value.find(u => u._id === userOnError._id);
|
||||
// if (userInSuggestions && userInSuggestions.photos) {
|
||||
// if (!userInSuggestions.photos.some(p => p.url)) {
|
||||
// // userInSuggestions.mainPhotoUrl = null; // Outdated line
|
||||
// }
|
||||
// }
|
||||
};
|
||||
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user