Hi all,
I’m encountering two significant issues on my client website
<?php
// Function to load and display images from a specific directory
function loadImages($directory) {
$images = glob($directory . "*.{jpg,png,jpeg,gif}", GLOB_BRACE);
if (!empty($images)) {
foreach ($images as $img) {
// Output image with basic HTML
echo '<img src="' . $img . '" alt="Image" />';
}
} else {
echo 'No images found.';
}
}
?>
What I've tried so far:
Thanks!
I’m encountering two significant issues on my client website
- Images not loading correctly: Some images appear to load halfway or are cropped.
- Slow page load times: The overall page loading speed is very slow, particularly on image-heavy pages.
<?php
// Function to load and display images from a specific directory
function loadImages($directory) {
$images = glob($directory . "*.{jpg,png,jpeg,gif}", GLOB_BRACE);
if (!empty($images)) {
foreach ($images as $img) {
// Output image with basic HTML
echo '<img src="' . $img . '" alt="Image" />';
}
} else {
echo 'No images found.';
}
}
?>
What I've tried so far:
- I ensured that the images are correctly stored on the server and optimized for the web (reduced size).
- I've looked into caching, but I haven’t implemented any solutions yet.
- The images load inconsistently, especially when there are multiple images on the page.
- Could this issue be caused by the way I’m loading images using PHP? Is there a more efficient way to handle image loading to avoid partial loading or cropping?
- Could this be related to PHP's memory management or server-side image handling?
- Are there any performance optimization strategies I can implement in PHP to improve the page load speed, especially with image-heavy content?
Thanks!
Attachments
Last edited by a moderator: