Path werkt niet bij afbeelding

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Mark Paulussen

Mark Paulussen

15/05/2024 16:00:39
Quote Anchor link
Goedendag, ik heb een image slider en een gallery die worden getoond als ingeladen pagina op de website. Los hiervan had ik ze functioneel maar zodra ze in de hoofdpagina geladen worden gaat het mis. Plaatjes worden niet gevonden dus heb ik de paden gecheckt maar waar ik ook mogelijk paden verander, gebeurt er niets. Nu mijn vraag: Moet ik op de één of andere manier de functies die worden aangeroepen ook voorzien van een pad o.i.d.? Dat het daar misgaat?

Mijn website heeft deze structuur:

Root
|
Map:Test (tijdelijk to hij werkt)
index.html (laadt die php pagina's in)
|
Map: imageSlider
index.php
Map: imageGallery
index.php

----------
Code index.php
---------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Image Gallery</title>
<link rel="stylesheet" href="imageGallery/style.css">
</head>
<body>
<div id="gallery">
  <?php include 'imageGallery/load_images.php'; ?>
</div>
<div id="popup" style="display:none;" onclick="closePopup()"> <img id="popup-img" src="" alt="Large image" onclick="closePopup()">
  <p>Image description and details here.</p>
  <button onclick="window.location.href='imageGallery/more-info.html';">More Information</button>
</div>
<script src="imageGallery/script.js"></script>
</body>
</html>


---------------
Code load_images.php
---------------
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>

<?php
$thumbnailDir
= 'thumbnails';
$fullSizeDir = 'fullsize';
$images = array_diff(scandir($thumbnailDir), array('..', '.'));

usort($images, function($a, $b) {
    return strnatcmp($b, $a);
});


echo '<div id="popup">';
echo '<img id="popup-img" src="" alt="Full size image" onclick="closePopup(event)">';
echo '<div class="overlay-text">';
echo '<p>Image details here</p>'; // Small text on the left
echo '<button class="close-button">Close</button>';
echo '<button onclick="moreInfo()">More Info</button>';
echo '</div>';
echo '</div>';

foreach ($images as $image) {
    $fullImagePath = $fullSizeDir . '/' . $image;
    $thumbnailPath = $thumbnailDir . '/' . $image;
    echo '<div class="thumbnail">';
    echo '<img src="' . $thumbnailPath . '" alt="Thumbnail of ' . $image . '" onclick="openPopup(\'' . $fullImagePath . '\')" />';
    echo '</div>';
}

?>
Gewijzigd op 15/05/2024 17:05:06 door - Ariën -
 
PHP hulp

PHP hulp

02/06/2024 07:19:41
 
- Ariën  -
Beheerder

- Ariën -

15/05/2024 16:03:12
Quote Anchor link
Rechtsklik eens op een 'dood' plaatje. Dan kan je de URL ziet die geprobeerd wordt te openen.
 
Mark Paulussen

Mark Paulussen

15/05/2024 16:33:04
Quote Anchor link
Ja daar probeert hij dit te openen:
<img src="thumbnails/image2.jpg" alt="Thumbnail of image2.jpg" onclick="openPopup('fullsize/image2.jpg')">

De source moet: imageGallery/thumbnails/image2.jpg zijn maar waar ik ook 'imageGallery/' voor zet, het werkt niet. Bijvoorbeeld bij fullimagePath
 
- Ariën  -
Beheerder

- Ariën -

15/05/2024 17:04:28
Quote Anchor link
Wat dacht je van $thumbnailDir ?
 
Mark Paulussen

Mark Paulussen

15/05/2024 17:51:29
Quote Anchor link
$fullImagePath = $fullSizeDir . '/' . $image;
$thumbnailPath = $thumbnailDir . '/' . $image;

Deze beide al eens in dit veranderd, maar lost niets op helaas :-(

$fullImagePath = $fullSizeDir . '/imageGallery' . $image;
$thumbnailPath = $thumbnailDir . '/imageGallery' . $image;

Toevoeging op 15/05/2024 17:52:18:

ook in het volledige pad: /imageGallery/thumbnails werkt niet

Toevoeging op 15/05/2024 18:04:14:

Ah, als ik die aanpas zet hij het op de verkeerde plek.
https://www.markpaulussen.com/test/thumbnails/imageGallery/image3.jpg

Toevoeging op 15/05/2024 18:08:55:

oke, nu heb ik op line 9: $thumbnailDir = 'thumbnails';
veranderd in: $thumbnailDir = 'imageGallery/thumbnails';

maar dan krijg ik weer een error.

Toevoeging op 15/05/2024 18:14:11:

Hij moet bij line 28!

echo '<img src="imageGallery/' . $thumbnailP.... etc.

haha, jeetje. Nu de rest nog aan de praat krijgen. Bedankt Ariën voor het duwtje :-)
 
- Ariën  -
Beheerder

- Ariën -

15/05/2024 18:22:57
Quote Anchor link
Mooi dat je hem hebt! :-)
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.