Allow product image with ID > 9 999 999 in PrestaShop
<?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