Olivier CLEMENCE Posted June 6, 2013 Share Posted June 6, 2013 (edited) Bonjour, j'i très légèrement modifié la class imageManager et je voulais faire ça proprement en faisant un override mais mon override n'est jamais pris en compte. Voici le code de mon override: <?php class ImageManager extends ImageManagerCore { /** * Resize, cut and optimize image * * @param string $src_file Image object from $_FILE * @param string $dst_file Destination filename * @param integer $dst_width Desired width (optional) * @param integer $dst_height Desired height (optional) * @param string $file_type * @return boolean Operation result */ public static function resize($src_file, $dst_file, $dst_width = null, $dst_height = null, $file_type = 'jpg', $force_type = false) { if (PHP_VERSION_ID < 50300) clearstatcache(); else clearstatcache(true, $src_file); if (!file_exists($src_file) || !filesize($src_file)) return false; list($src_width, $src_height, $type) = getimagesize($src_file); // If PS_IMAGE_QUALITY is activated, the generated image will be a PNG with .jpg as a file extension. // This allow for higher quality and for transparency. JPG source files will also benefit from a higher quality // because JPG reencoding by GD, even with max quality setting, degrades the image. if (Configuration::get('PS_IMAGE_QUALITY') == 'png_all' || (Configuration::get('PS_IMAGE_QUALITY') == 'png' && $type == IMAGETYPE_PNG) && !$force_type) $file_type = 'png'; if (!$src_width) return false; if (!$dst_width) $dst_width = $src_width; if (!$dst_height) $dst_height = $src_height; $src_image = ImageManager::create($type, $src_file); $width_diff = $dst_width / $src_width; $height_diff = $dst_height / $src_height; if ($width_diff > 1 && $height_diff > 1) { $next_width = $src_width; $next_height = $src_height; } else { if (Configuration::get('PS_IMAGE_GENERATION_METHOD') == 2 || (!Configuration::get('PS_IMAGE_GENERATION_METHOD') && $width_diff > $height_diff)) { $next_height = $dst_height; $next_width = round(($src_width * $next_height) / $src_height); $dst_width = (int)(!Configuration::get('PS_IMAGE_GENERATION_METHOD') ? $dst_width : $next_width); } else { $next_width = $dst_width; $next_height = round($src_height * $dst_width / $src_width); $dst_height = (int)(!Configuration::get('PS_IMAGE_GENERATION_METHOD') ? $dst_height : $next_height); } } if (!ImageManager::checkImageMemoryLimit($src_file)) return false; $dest_image = imagecreatetruecolor($dst_width, $dst_height); // If image is a PNG and the output is PNG, fill with transparency. Else fill with white background. /*if ($file_type == 'png' && $type == IMAGETYPE_PNG) {*/ imagealphablending($dest_image, false); imagesavealpha($dest_image, true); $transparent = imagecolorallocatealpha($dest_image, 255, 255, 255, 127); imagefilledrectangle($dest_image, 0, 0, $dst_width, $dst_height, $transparent); /*} else { $white = imagecolorallocate($dest_image, 255, 255, 255); imagefilledrectangle ($dest_image, 0, 0, $dst_width, $dst_height, $white); }*/ imagecopyresampled($dest_image, $src_image, (int)(($dst_width - $next_width) / 2), (int)(($dst_height - $next_height) / 2), 0, 0, $next_width, $next_height, $src_width, $src_height); return (ImageManager::write($file_type, $dest_image, $dst_file)); } } Quelqu'un aurait une idée ? Ps: j'ai juste supprimer le la condition sur les png pour que le fond blanc ne soit jamais appliqué et si je fait cette modif directe dans le imageManager (sans override donc) ça marche sans problème. Edited June 6, 2013 by maniT4c (see edit history) Link to comment Share on other sites More sharing options...
Olivier CLEMENCE Posted June 6, 2013 Author Share Posted June 6, 2013 ok j'avais qu'a lire la documentation car c'est indiqué dedans: http://doc.prestashop.com/display/PS15/Overriding+default+behaviors Pour info il faut supprimer le fichier "cache/class_index.php" pour que l'override soit pris en compte. Ce fichier sera automatiquement regénéré. Link to comment Share on other sites More sharing options...
byl14 Posted November 4, 2013 Share Posted November 4, 2013 Bjr j'ai tenté la même démarche et les cadres blancs sont toujours là! Même en réécrivant directement la classe imageManager Une idée... Link to comment Share on other sites More sharing options...
Olivier CLEMENCE Posted November 4, 2013 Author Share Posted November 4, 2013 Pour info il faut supprimer le fichier "cache/class_index.php" pour que l'override soit pris en compte. Que ce soit en override ou directement dans la class les modifs ne seront prises en compte que si class_index.php aura été supprimé dans le dossier cache. Link to comment Share on other sites More sharing options...
byl14 Posted November 4, 2013 Share Posted November 4, 2013 je l'ai fais à plusieurs reprises déjà... Link to comment Share on other sites More sharing options...
Olivier CLEMENCE Posted November 5, 2013 Author Share Posted November 5, 2013 Etrange, peut-être que cet override ne marche plus en 1.5.6 à l'époque je l'avais testé sur une 1.5.2 je crois. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now