Images not loading fully and slow page load times on my client website

devjoe

New member
Hi all,

I’m encountering two significant issues on my client website

  1. Images not loading correctly: Some images appear to load halfway or are cropped.
  2. Slow page load times: The overall page loading speed is very slow, particularly on image-heavy pages.
I'm currently using the following PHP code to handle image loading on the site:
<?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.
My questions:

  1. 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?
  2. Could this be related to PHP's memory management or server-side image handling?
  3. Are there any performance optimization strategies I can implement in PHP to improve the page load speed, especially with image-heavy content?
Any insights, fixes, or optimization tips would be greatly appreciated.

Thanks!Screenshot 2024-09-13 091032.png
 

Attachments

  • Screenshot 2024-09-12 132209.png
    Screenshot 2024-09-12 132209.png
    124 KB · Views: 1
Last edited by a moderator:
Back
Top