Created
December 15, 2020 18:08
-
-
Save Shagshag/9b7ca766e6a855ba17d8af9c71412076 to your computer and use it in GitHub Desktop.
Allow product image with ID > 9 999 999 in PrestaShop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PageNotFoundController extends PageNotFoundControllerCore | |
{ | |
public function initContent() | |
{ | |
list($filename) = explode('?', substr($_SERVER['REQUEST_URI'], 6)); | |
if (preg_match('/([0-9]+)(\-[_a-zA-Z0-9-]*)?\/.*\.jpg/', $filename, $matches)) { | |
$path = _PS_ROOT_DIR_.'/img/p/'.implode('/', str_split($matches[1], 1)).'/'.$matches[1].$matches[2].'.jpg'; | |
if (file_exists($path)) { | |
header('Content-Type: '.mime_content_type($path)?:'image/jpg'); | |
readfile($path); | |
die(); | |
} else { | |
header('HTTP/1.1 404 Not Found'); | |
header('Status: 404 Not Found'); | |
header('Content-Type: image/gif'); | |
readfile(_PS_ROOT_DIR_.'/img/404.gif'); | |
die(); | |
} | |
} | |
return parent::initContent(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment