fix: Convert images to associative array (#89)

This commit is contained in:
Jonah Lawrence 2023-01-15 10:30:35 -07:00 committed by GitHub
parent 6bce574b1d
commit ecb7145f6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -80,12 +80,12 @@ if (preg_match("/\/images\/(.*)$/", $_SERVER['REQUEST_URI'], $matches)) {
} }
// fetch the list of images from GitHub // fetch the list of images from GitHub
$images = json_decode(curlGetContents($GITHUB_API_URL, $REPO)); $images = json_decode(curlGetContents($GITHUB_API_URL, $REPO), true);
// if the random query string parameter is set, pick a random image // if the random query string parameter is set, pick a random image
if (isset($_GET['random'])) { if (isset($_GET['random'])) {
// get the image url // get the image url
$random_image_path = $images[array_rand($images)]->download_url; $random_image_path = $images[array_rand($images)]["download_url"];
displayImage($random_image_path, $REPO, $redirect); displayImage($random_image_path, $REPO, $redirect);
} }
?> ?>
@ -225,7 +225,7 @@ if (isset($_GET['random'])) {
<div class="gallery"> <div class="gallery">
<?php foreach ($images as $image) : ?> <?php foreach ($images as $image) : ?>
<?php $image_path = $image->download_url; ?> <?php $image_path = $image["download_url"]; ?>
<a href="<?= $image_path; ?>" class="glightbox" data-alt="<?= basename($image_path); ?>" data-description="<?= basename($image_path); ?>"> <a href="<?= $image_path; ?>" class="glightbox" data-alt="<?= basename($image_path); ?>" data-description="<?= basename($image_path); ?>">
<img src="<?= $IMGPROXY_PREFIX . basename($image_path); ?>" loading="lazy" alt="<?= basename($image_path); ?>" title="<?= basename($image_path); ?>" class="loading" onload="this.classList.remove('loading')"> <img src="<?= $IMGPROXY_PREFIX . basename($image_path); ?>" loading="lazy" alt="<?= basename($image_path); ?>" title="<?= basename($image_path); ?>" class="loading" onload="this.classList.remove('loading')">
</a> </a>