QloApps Forums
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Cover images on /our-properties page always show placeholder due to HTTP image existence check

    Bug Report
    code cover image image check php local
    1
    1
    21
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • I
      iamfhil last edited by

      In controllers/front/OurPropertiesController.php, the code attempts to verify the hotel cover image's existence by fetching the image URL using Tools::file_get_contents(). This check fails on many environments (especially offline/local) even when the image file exists, causing the fallback to the default placeholder (hotel-default-icon.png). This logic makes valid hotel cover images not display on the Our Properties page.

      Actual behaviour:
      Hotel cover images (that exist on disk and display correctly in admin and on room pages) are replaced with the default placeholder on the frontend list.

      Expected behaviour:
      The cover image URL should be used directly, just like admin and room pages do, without trying to fetch it over HTTP.

      Reproduction steps:

      • Install QloApps 1.7.x with one or more hotels and associated cover images.

      • Ensure images exist under:
        modules/hotelreservationsystem/views/img/hotel_img/{hotel_id}/{imagefile}.jpg

      • Ensure the server is fully set up for the production environment, not the dev. I encountered this possibly after making some config changes to harden Apache/PHP. Not sure what exact setting, but the point is that the HTTP check fails. During that time, I also switched locales. The point is I have fully prepared to deploy to production when this occurred. Didn't happen while I was still doing dev work.

      • Visit /our-properties page.

      • Images show a placeholder instead of real cover images.

      Root cause:
      The controller checks image existence with this code:

      if ((bool)Tools::file_get_contents($htlImgLink)) {
          $hotelsInfo[$hotelKey]['image_url'] = $htlImgLink;
      } else {
          $hotelsInfo[$hotelKey]['image_url'] = $hotelIconDefault;
      }
      

      Fetching a URL with file_get_contents() is unreliable and not needed; it often fails under typical server settings.

      Fix (example):
      Replace the above test with a direct assignment:

      $hotelsInfo[$hotelKey]['image_url'] = $this->context->link->getMediaLink(
          $objHotelImage->getImageLink(
              $hotel['id_cover_img'],
              ImageType::getFormatedName('medium')
          )
      );
      

      This matches how images are resolved in other parts of QloApps.

      Environment:
      QloApps 1.7.0.0 (PrestaShop 1.6-based), offline/local development, caching disabled.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post