Skip to content

Commit

Permalink
Display images OK
Browse files Browse the repository at this point in the history
  • Loading branch information
Kherset committed Sep 25, 2023
1 parent 9823687 commit 066d495
Show file tree
Hide file tree
Showing 143 changed files with 229 additions and 51 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified assets/.DS_Store
Binary file not shown.
Binary file removed assets/images/Sample Photos/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed assets/images/Sample Photos/Marcel/Travel_Tower.jpg
Binary file not shown.
Binary file removed assets/images/Sample Photos/Mimi/.DS_Store
Binary file not shown.
Binary file removed assets/images/Sample Photos/Mimi/Animals_Rainbow.jpg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed assets/images/Sample Photos/Mimi/Portrait_Nora.jpg
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed assets/images/Sample Photos/Nabeel/.DS_Store
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed assets/images/Sample Photos/Rhode/Event_Emcee.jpg
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed assets/images/Sample Photos/Rhode/Fashion_Wings.jpg
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed assets/images/Sample Photos/Tracy/Art_Mine.jpg
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file not shown.
Binary file added assets/medias/195/Architecture_Contrast.jpg
Binary file added assets/medias/195/Architecture_Corner_Room.jpg
Binary file added assets/medias/195/Architecture_Dome.jpg
Binary file added assets/medias/195/Architecture_On_a_hill.jpg
Binary file added assets/medias/195/Travel_Adventure_Door.jpg
Binary file added assets/medias/195/Travel_Bike_and_Stair.jpg
Binary file added assets/medias/195/Travel_OpenMountain.jpg
Binary file added assets/medias/195/Travel_SunsetonCanals.jpg
Binary file added assets/medias/195/Travel_Tower.jpg
Binary file added assets/medias/243/Animals_Rainbow.jpg
Binary file added assets/medias/243/Event_BenevidesWedding.jpg
Binary file added assets/medias/243/Event_PintoWedding.jpg
Binary file added assets/medias/243/Event_SeasideWedding.jpg
Binary file added assets/medias/243/Portrait_Background.jpg
Binary file added assets/medias/243/Portrait_Nora.jpg
Binary file added assets/medias/243/Portrait_Wednesday.jpg
Binary file added assets/medias/243/Travel_HillsideColor.jpg
Binary file added assets/medias/243/Travel_Lonesome.jpg
Binary file added assets/medias/527/Portrait_AfternoonBreak.jpg
Binary file added assets/medias/527/Portrait_Alexandra.jpg
Binary file added assets/medias/527/Portrait_Shaw.jpg
Binary file added assets/medias/527/Portrait_Sunkissed.jpg
Binary file added assets/medias/527/Travel_Boat_Wanderer.jpg
Binary file added assets/medias/527/Travel_Bridge_into_Forest.jpg
Binary file added assets/medias/527/Travel_On_the_Road.jpg
Binary file added assets/medias/527/Travel_Outdoor_Baths.jpg
Binary file added assets/medias/527/Travel_Road_into_Hill.jpg
File renamed without changes.
Binary file added assets/medias/82/Art_Mine.jpg
Binary file added assets/medias/82/Art_Purple_light.jpg
Binary file added assets/medias/82/Art_Triangle_Man.jpg
Binary file added assets/medias/82/Event_18thAnniversary.jpg
Binary file added assets/medias/82/Event_Sparklers.jpg
Binary file added assets/medias/82/Event_WeddingGazebo.jpg
Binary file added assets/medias/82/Fashion_Pattern_on_Pattern.jpg
Binary file added assets/medias/82/Fashion_Urban_Jungle.jpg
Binary file added assets/medias/82/Fashion_Yellow_Beach.jpg
Binary file added assets/medias/925/Animals_Majesty.jpg
File renamed without changes.
Binary file added assets/medias/925/Event_Emcee.jpg
Binary file added assets/medias/925/Event_KeyboardCheck.jpg
Binary file added assets/medias/925/Event_ProductPitch.jpg
Binary file added assets/medias/925/Event_VentureConference.jpg
Binary file added assets/medias/925/Fashion_Wings.jpg
Binary file added assets/medias/925/Sport_2000_with_8.jpg
Binary file added assets/medias/925/Sport_Butterfly.jpg
Binary file added assets/medias/930/Architecture_Cross_Bar.jpg
Binary file added assets/medias/930/Architecture_Horseshoe.jpg
Binary file added assets/medias/930/Architecture_White_Light.jpg
Binary file added assets/medias/930/Sport_Jump.jpg
Binary file added assets/medias/930/Sport_Next_Hold.jpg
Binary file added assets/medias/930/Sport_Race_End.jpg
Binary file added assets/medias/930/Sport_Sky_Cross.jpg
Binary file added assets/medias/930/sport_water_tunnel.jpg
Binary file added assets/medias/IDPhotos/EllieRoseWilkens.jpg
Binary file added assets/medias/IDPhotos/MarcelNikolic.jpg
Binary file added assets/medias/IDPhotos/MimiKeel.jpg
Binary file added assets/medias/IDPhotos/NabeelBradford.jpg
Binary file added assets/medias/IDPhotos/RhodeDubois.jpg
Binary file added assets/medias/IDPhotos/TracyGalindo.jpg
File renamed without changes
66 changes: 61 additions & 5 deletions css/photographer.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/****************** Header ******************/
header {
align-items: center;
background-color: darkcyan;
background-color: lightgray;
display: flex;
height: 200px;
justify-content: space-between;
Expand Down Expand Up @@ -223,12 +223,68 @@ form input {
content: "";
display: block;
position: absolute;
left: 5%; /* Ajustez la valeur de la position horizontale selon vos besoins */
right: 5%; /* Ajustez la valeur de la position horizontale selon vos besoins */
left: 5%;
right: 5%;
top: 40px;
width: 90%; /* Ajustez la largeur de la bordure inférieure selon vos besoins */
border-top: 1px solid white; /* Épaisseur et couleur de la bordure inférieure */
width: 90%;
border-top: 1px solid white;
z-index: 2;
}

/****************** DropDown Menu ******************/

/****************** Medias ******************/
#medias-container {
display: grid;
height: auto;
grid-template-columns: repeat(3, 1fr);
gap: 60px;
margin: 30px 100px 50px;
width: auto;
}

.medias-item {
background-color: white;
border-radius: 5px;
display: flex;
flex-direction: column;
justify-content: center;
height: 250px;
width: auto;
box-sizing: border-box;
}

.img-container {
position: relative;
width: 100%;
height: 300px;
}

.media-item {
position: absolute;
top: 0;
left: 0;
object-fit: cover;
width: 100%;
height: 100%;
border-radius: 5px;
}

.item-content {
display: flex;
justify-content: space-between;
color: #901C1C;
margin-top: 10px;
box-sizing: border-box;
}

.likes {
display: flex;
justify-content: space-between;
}

.likes-icon {
margin-left: 5px;
}

/****************** Medias ******************/
8 changes: 4 additions & 4 deletions data/photographers.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
{
"id": 34513453,
"photographerId": 527,
"title": "Shaw Potrait",
"title": "Shaw Portrait",
"image": "Portrait_Shaw.jpg",
"likes": 52,
"date": "2017-04-21",
Expand Down Expand Up @@ -331,7 +331,7 @@
{
"id": 2525345343,
"photographerId": 243,
"title": "Wednesday Potrait",
"title": "Wednesday Portrait",
"image": "Portrait_Wednesday.jpg",
"likes": 34,
"date": "2019-04-07",
Expand Down Expand Up @@ -413,7 +413,7 @@
{
"id": 2523434,
"photographerId": 195,
"title": "Senset on Canals, Venice",
"title": "Sunset on Canals, Venice",
"image": "Travel_SunsetonCanals.jpg",
"likes": 53,
"date": "2019-05-06",
Expand Down Expand Up @@ -494,7 +494,7 @@
{
"id": 952343423,
"photographerId": 930,
"title": "Tricks in te air",
"title": "Tricks in the air",
"video": "Sport_Tricks_in_the_air.mp4",
"likes": 150,
"date": "2018-02-30",
Expand Down
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<meta charset="utf-8">
<link rel="icon" type="image/png" href="assets/favicon.png">
<link href="https://fonts.googleapis.com/css?family=DM+Sans&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/8f5705fdf5.js" crossorigin="anonymous"></script>
<title>Fisheye</title>
</head>
<body>
<nav>
<a href="index.html" class="homepage-link" aria-label="Logo du site redirigeant vers la page d'accueil"> <img src="assets/images/logo.png" class="logo" alt="Fisheye Home page"/> </a>
<a href="index.html" class="homepage-link" aria-label="Logo du site redirigeant vers la page d'accueil"> <img src="assets/medias/logo.png" class="logo" alt="Fisheye Home page"/> </a>
<h1 aria-label="Nos photographes">Nos photographes</h1>
</nav>
<main id="main">
Expand Down
11 changes: 9 additions & 2 deletions photographer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<meta charset="utf-8">
<link rel="icon" type="image/png" href="assets/favicon.png">
<link href="https://fonts.googleapis.com/css?family=DM+Sans&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/8f5705fdf5.js" crossorigin="anonymous"></script>
<title>Fisheye - photographe </title>
</head>
<body>
<nav>
<a href="index.html" class="homepage-link" aria-label="Logo du site redirigeant vers la page d'accueil"> <img src="assets/images/logo.png" class="logo" alt="Fisheye Home page"/> </a>
<a href="index.html" class="homepage-link" aria-label="Logo du site redirigeant vers la page d'accueil"> <img src="assets/medias/logo.png" class="logo" alt="Fisheye Home page"/> </a>
</nav>

<header>
Expand Down Expand Up @@ -37,9 +38,15 @@ <h4 class="sort_title">Trier par </h4>
</div>
</div>
</div>

<section id="medias-container">

</section>
</main>



<!-- Modal -->
<div id="contact_modal">
<div class="modal">
<header>
Expand All @@ -55,7 +62,7 @@ <h2>Contactez-moi</h2>
</form>
</div>
</div>

<!-- Modal -->


<script src="/scripts/templates/photographer.js" ></script>
Expand Down
106 changes: 72 additions & 34 deletions scripts/pages/photographer.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,80 @@
// Allows to retrieve the photographer's ID.
let params = new URL(document.location).searchParams;
let id = parseInt(params.get("id"));

// Allows to retrieve all photographers from the JSON file.
async function getPhotographers() {
try {
const response = await fetch('data/photographers.json');
if (!response.ok) {
throw new Error('Unable to retrieve photographer data.');
let params = new URL(document.location).searchParams;
let id = parseInt(params.get("id"));

/**************************************** Photographers ****************************************/
// Allows to retrieve all photographers from the JSON file.
async function getPhotographers() {
try {
const response = await fetch('data/photographers.json');
if (!response.ok) {
throw new Error('Unable to retrieve photographer data.');
}
const data = await response.json();
return data.photographers;
} catch (error) {
console.error(error);
return [];
}
}

// Allows to retrieve a photographer from his ID.
async function getPhotographersById(id) {
const photographers = await getPhotographers();

const photographer = photographers.find(function (photographer) {
return photographer.id === id;
});

if (photographer) {
console.log("Photographer found :", photographer);
return photographer;
} else {
console.log("No photographer found with the ID", id);
return null;
}
}
const data = await response.json();
return data.photographers;
} catch (error) {
console.error(error);
return [];

async function displayPhotographer() {
const photographer = await getPhotographersById(id) // Photographer object retrieved.
photographerHeader(photographer)
}
}

// Allows to retrieve a photographer from his ID.
async function getPhotographersById(id) {
const photographers = await getPhotographers();

const photographer = photographers.find(function (photographer) {
return photographer.id === id;
});

if (photographer) {
console.log("Photographer found :", photographer);
return photographer;
} else {
console.log("No photographer found with the ID", id);
return null;
}
}
/**************************************** Medias ****************************************/
// Allows to retrieve all photographers from the JSON file.
async function getMedias() {
try {
const response = await fetch('data/photographers.json');
if (!response.ok) {
throw new Error('Unable to retrieve medias data.');
}
const data = await response.json();
return data.media;
} catch (error) {
console.error(error);
return [];
}
}

// Allows the use of the photographer's ID to retrieve the associated media.
async function getMediasByPhotographerId(id) {
const medias = await getMedias();
return medias.filter(media => media.photographerId === id);
}

getMediasByPhotographerId(id)

async function displayMedias() {
const medias = await getMediasByPhotographerId(id) // Photographer object retrieved.
medias.forEach(media => {
createMedias(media)
});

async function displayPhotographer() {
const photographer = await getPhotographersById(id) // Photographer object retrieved.
photographerHeader(photographer)
}





displayPhotographer()
displayMedias()
2 changes: 1 addition & 1 deletion scripts/templates/homepage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function homepageTemplate(data) {
const { name, portrait, city, country, tagline, price, id } = data;

const picture = `assets/images/Sample Photos/Photographers ID Photos/${portrait}`;
const picture = `assets/medias/IDPhotos/${portrait}`;

function getUserCardDOM() {
const article = document.createElement( 'article' );
Expand Down
84 changes: 80 additions & 4 deletions scripts/templates/photographer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
function photographerHeader(data) {
const { name, portrait, city, country, tagline,} = data;
const picture = `assets/medias/IDPhotos/${portrait}`;

const { name, portrait, city, country, tagline, price, id } = data;
const picture = `assets/images/Sample Photos/Photographers ID Photos/${portrait}`;

const photographerContent = document.querySelector('.photographer-content')
const photographerName = document.querySelector('.photographer-name')
const photographerLocation = document.querySelector('.photographer-location')
const photographerDescription = document.querySelector('.photographer-description')
Expand All @@ -14,3 +12,81 @@ function photographerHeader(data) {
photographerDescription.textContent = `${tagline}`;
photographerPhoto.setAttribute('src', `${picture}`)
}


function createMedias(data) {
const { id, photographerId, title, image, video, likes, date, price} = data;
const imageMedia = `assets/medias/${photographerId}/${image}`;
const videoMedia = `assets/medias/${photographerId}/${video}`;
const mediasContainer = document.getElementById('medias-container');

// Create media element
const article = document.createElement('article')
article.className ='medias-item'

// Create image container
const imageContainer = document.createElement('div')
imageContainer.className ='img-container'

// Create image or video element
const imageOrVideo = (data) => {
if (data && (data.image || data.video)) {
if (data.image && (data.image.endsWith('.jpg') || data.image.endsWith('.jpeg') || data.image.endsWith('.png'))) {
const image = document.createElement('img');
image.src = `assets/medias/${data.photographerId}/${data.image}`;
return image;
} else if (data.video && data.video.endsWith('.mp4')) {
const video = document.createElement('video');
video.src = `assets/medias/${data.photographerId}/${data.video}`;
video.controls = true;
return video;
}
}
// Si aucune image ni vidéo valide n'est trouvée, vous pouvez renvoyer null ou un élément de remplacement, par exemple un message d'erreur.
return null;
};
const mediaElement = imageOrVideo(data);
mediaElement.className = "media-item"

// Create item content
const itemContent = document.createElement('div')
itemContent.className ='item-content'

// Create title element
const mediaTitle = document.createElement('h4');
mediaTitle.className ='item-title'
mediaTitle.textContent = title;

// Create item content
const likesContainer = document.createElement('div')
likesContainer.className ='likes'

// Create number of like element
const likesElement = document.createElement('div');
likesElement.className ='likes'

// Create number of number of like element
const mediaNumber = document.createElement('p');
mediaNumber.className ='likes-number'
mediaNumber.textContent = likes;

// Create item icon
const likesIcon = document.createElement('p')
likesIcon.className ='likes-icon'
likesIcon.innerHTML = '<i class="fa-solid fa-heart"></i>'



// Building page
mediasContainer.appendChild(article)
article.appendChild(imageContainer)
imageContainer.appendChild(mediaElement)
article.appendChild(itemContent)
itemContent.appendChild(mediaTitle)
itemContent.appendChild(likesElement)
likesElement.appendChild(mediaNumber)
likesElement.appendChild(likesIcon)

// article.appendChild()

}

0 comments on commit 066d495

Please sign in to comment.