add channel avatar

This commit is contained in:
2025-04-09 08:40:03 +04:00
parent f06c9a4f76
commit 2b8d6d94f9
3 changed files with 66 additions and 3 deletions
+30
View File
@@ -415,6 +415,36 @@ img {
font-size: 14px; font-size: 14px;
color: #555; color: #555;
margin-bottom: 8px; margin-bottom: 8px;
display: flex;
align-items: center;
overflow: hidden;
}
.channel-avatar {
width: 24px;
height: 24px;
border-radius: 50%;
margin-right: 8px;
object-fit: cover;
flex-shrink: 0;
border: 1px solid #e5e5e5;
}
.channel-avatar-placeholder {
width: 24px;
height: 24px;
border-radius: 50%;
margin-right: 8px;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
background-color: #e5e5e5;
color: #666;
font-size: 16px;
}
.channel-name {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
+6
View File
@@ -274,6 +274,11 @@ function formatVideosData($videosData) {
$thumbnail = isset($video['previewPath']) $thumbnail = isset($video['previewPath'])
? PEERTUBE_URL . $video['previewPath'] ? PEERTUBE_URL . $video['previewPath']
: 'img/default-thumbnail.jpg'; : 'img/default-thumbnail.jpg';
// Récupérer l'avatar de la chaîne
$channelAvatar = isset($video['channel']['avatars'][0]['path']) && isset($video['channel']['avatars'][0]['path'])
? PEERTUBE_URL . $video['channel']['avatars'][0]['path']
: 'img/default-avatar.png';
// Formater les données // Formater les données
$videos[] = [ $videos[] = [
@@ -282,6 +287,7 @@ function formatVideosData($videosData) {
'thumbnail' => $thumbnail, 'thumbnail' => $thumbnail,
'duration' => $video['duration'], 'duration' => $video['duration'],
'channel' => $video['channel']['displayName'], 'channel' => $video['channel']['displayName'],
'channelAvatar' => $channelAvatar,
'views' => $video['views'], 'views' => $video['views'],
'date' => $video['publishedAt'], 'date' => $video['publishedAt'],
'aspectRatio' => $video['aspectRatio'], 'aspectRatio' => $video['aspectRatio'],
+30 -3
View File
@@ -218,7 +218,16 @@
</div> </div>
<div class="video-info"> <div class="video-info">
<h3 class="video-title"><?php echo $video['title']; ?></h3> <h3 class="video-title"><?php echo $video['title']; ?></h3>
<div class="video-channel"><?php echo $video['channel']; ?></div> <div class="video-channel">
<?php if (strpos($video['channelAvatar'], 'default-avatar.png') !== false || empty($video['channelAvatar'])): ?>
<div class="channel-avatar-placeholder">
<i class="fas fa-user-circle"></i>
</div>
<?php else: ?>
<img src="<?php echo $video['channelAvatar']; ?>" alt="<?php echo $video['channel']; ?>" class="channel-avatar">
<?php endif; ?>
<span class="channel-name"><?php echo $video['channel']; ?></span>
</div>
<div class="video-metadata"> <div class="video-metadata">
<span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span> <span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span>
<span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span> <span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span>
@@ -264,7 +273,16 @@
</div> </div>
<div class="video-info"> <div class="video-info">
<h3 class="video-title"><?php echo $video['title']; ?></h3> <h3 class="video-title"><?php echo $video['title']; ?></h3>
<div class="video-channel"><?php echo $video['channel']; ?></div> <div class="video-channel">
<?php if (strpos($video['channelAvatar'], 'default-avatar.png') !== false || empty($video['channelAvatar'])): ?>
<div class="channel-avatar-placeholder">
<i class="fas fa-user-circle"></i>
</div>
<?php else: ?>
<img src="<?php echo $video['channelAvatar']; ?>" alt="<?php echo $video['channel']; ?>" class="channel-avatar">
<?php endif; ?>
<span class="channel-name"><?php echo $video['channel']; ?></span>
</div>
<div class="video-metadata"> <div class="video-metadata">
<span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span> <span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span>
<span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span> <span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span>
@@ -310,7 +328,16 @@
</div> </div>
<div class="video-info"> <div class="video-info">
<h3 class="video-title"><?php echo $video['title']; ?></h3> <h3 class="video-title"><?php echo $video['title']; ?></h3>
<div class="video-channel"><?php echo $video['channel']; ?></div> <div class="video-channel">
<?php if (strpos($video['channelAvatar'], 'default-avatar.png') !== false || empty($video['channelAvatar'])): ?>
<div class="channel-avatar-placeholder">
<i class="fas fa-user-circle"></i>
</div>
<?php else: ?>
<img src="<?php echo $video['channelAvatar']; ?>" alt="<?php echo $video['channel']; ?>" class="channel-avatar">
<?php endif; ?>
<span class="channel-name"><?php echo $video['channel']; ?></span>
</div>
<div class="video-metadata"> <div class="video-metadata">
<span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span> <span class="video-views"><i class="fas fa-eye"></i> <?php echo formatViewCount($video['views']); ?> vues</span>
<span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span> <span class="video-date"><i class="far fa-calendar-alt"></i> <?php echo formatDate($video['date']); ?></span>