cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.3.5 gd2.php adds new condition that prevents images from displaying

SOLVED

Magento 2.3.5 gd2.php adds new condition that prevents images from displaying

There is a new check in /vendor/magento/framework/image/adapter/Gd2.php on line 62

              if (!$filename || filesize($filename) === 0 || !$this->validateURLScheme($filename))

The validateURLScheme is new and that function performs a check to ensure the file is referenced with the following labels:

                      $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];

The system Im developing on is Windows and the image passed file is referenced by a directory structure (ie: D:/xampp/htdocs ..... ) and so it fails this test.  Putting a return true at this function allows me to continue but makes me wonder if Ive applied my images in the wrong way into the system.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2.3.5 gd2.php adds new condition that prevents images from displaying

Hi @virgil_long 

Find validateURLScheme function in below file.

vendor\magento\framework\Image\Adapter\Gd2.php

at line 96. Replace function with this:

private function validateURLScheme(string $filename) : bool
  {
      $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
      $url = parse_url($filename);
      if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) {
          return false;
      }

      return true;
  }


If issue resolve, please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

View solution in original post

3 REPLIES 3

Re: Magento 2.3.5 gd2.php adds new condition that prevents images from displaying

@virgil_long 

 

Yes this has been added to check $this->validateURLScheme($filename)

 

$allowed_schemes = ['ftp', 'ftps', 'http', 'https'];

 

Most of window system faced this error during local development. It will work on your live server. So for local you can skip this.

Manish Mittal
https://www.manishmittal.com/

Re: Magento 2.3.5 gd2.php adds new condition that prevents images from displaying

Hi @virgil_long 

Find validateURLScheme function in below file.

vendor\magento\framework\Image\Adapter\Gd2.php

at line 96. Replace function with this:

private function validateURLScheme(string $filename) : bool
  {
      $allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
      $url = parse_url($filename);
      if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) {
          return false;
      }

      return true;
  }


If issue resolve, please click on 'Kudos' & Accept as Solution!

Problem solved? Click Accept as Solution!

Re: Magento 2.3.5 gd2.php adds new condition that prevents images from displaying

&& !file_exists($filename)) this part was missing on my site. thanks a lot bro.