shagshag 109 Posted May 5, 2008 Posted May 5, 2008 Bonjour, Text in english below Voici un module un peu technique pour les personnes qui créent leurs propres templates. Il permet de redimensionner les images produits/catégories ou autre depuis les fichiers templates. il ajoute 2 modificateurs à Smarty : picture_resize : pour redimensionner les images Usage : {"picture_path"|picture_resize:width:height:'method':'border_color'} exemple : {"$img_prod_dir`$product.id_image`.jpg"|picture_resize:300:200:'dontCrop':'#FFFFFF'} écrira <img src="path/to/thumb" width="300" height="200" alt="" /> et l'image aura des bords blancs. add_attribute : pour ajouter un attribut à une balise HTML Usage : {"HTML tag"|add_attribute:'attribute_name':'attribute_value'} exemple : {"$img_prod_dir`$product.id_image`.jpg"|picture_resize:300:200|add_attribute:'alt':$product.legend} écrira <img src="path/to/thumb" width="300" height="200" alt="my product legend" /> Comme j'ai déjà écrit la doc plus précise en anglais je ne la remet pas en français (pfff) N'hésitez pas à proposer des corrections/améliorations. In english now This is a Prestashop module that allow templates create thumbnails It add 2 functions to smarty : picture_resize : resize picture Usage : {"picture_path"|picture_resize:width:height:'method':'border_color'} exemple : {"$img_prod_dir`$product.id_image`.jpg"|picture_resize:300:200:'dontCrop':'#FFFFFF'} will return <img src="path/to/thumb" width="300" height="200" alt="" /> and picture will have white border. parameters : [li]1) width in pixel or '*' for original width (default '*')[/li] [li]2) height in pixel or '*' for original height (default '*')[/li] [li]3) method : 'crop' or 'dontCrop' (default). dontCrop will show all the picture with border, crop resize the picture and crop it.[/li] [li]4) border_color : border color for method 'dontCrop'. default '#FFFFFF'[/li] note : [li]generated pictures are saved in /img/thumbgenerator and are re-generated once a day.[/li] [li]all parameters are optional : {"picture_path"|picture_resize} will copy picture in cache folder and return <img src... />[/li] add_attribute : add html attribute to a tag. Usage : {"HTML tag"|add_attribute:'attribute_name':'attribute_value'} exemple : {"$img_prod_dir`$product.id_image`.jpg"|picture_resize:300:200|add_attribute:'alt':$product.legend} will return <img src="path/to/thumb" width="300" height="200" alt="my product legend" /> Some of the code come from SPIP CMS (http://www.spip.net), Smarty library (http://www.smarty.net) and Prestashop (of course) Regards thumbgenerator.zip Share this post Link to post Share on other sites
boutikfacile 0 Posted May 9, 2008 Posted May 9, 2008 Je ne comprend pas le but, désolé, veux tu bien m'expliquer juste à quoi ca sert ? Share this post Link to post Share on other sites
shagshag 109 Posted May 13, 2008 Posted May 13, 2008 Bonjour, Yep, j'ai été trop technique et pas assez clair. En fait je trouve le système de miniature de Prestashop trop rigide. actuellement il y a une couleur de fond pour toutes les tailles d'images, les tailles d'images sont fixées dans l'administration alors qu'elles devraient l'être dans le template (maintenant il y a le fichier conf.xml qui a l'air de régler ça mais je ne sais pas comment il marche), la régénération des vignettes n'est pas au point. Tout ceci est réglable en modifiant les fichiers de l'administration de Prestashop, j'avais commencé à le faire mais ce n'est pas une bonne méthode (à chaque mise à jour faut tout refaire) donc j'ai fait ce module. Il sert de remplacement à la génération de miniature. Actuellement dans le template pour afficher une petite image d'un produit on fait comme ceci : <img src="{$img_prod_dir}{$product.id_image}-small.jpg" alt="{$product.legend}" /> ou small est le type de vignette prédéfini dans l'admin. Avec le module on fait comme ça : {"$img_prod_dir`$product.id_image`.jpg"|picture_resize:150:100} et la vignette fera 150px sur 100px. c'est beaucoup plus pratique pour les designer et pour les personnes qui installe les templates. on peut aller plus loin: {"$img_prod_dir`$product.id_image`.jpg"|picture_resize:150:100} affiche une vignette avec un bord blanc comme par défaut dans prestashop. {"$img_prod_dir`$product.id_image`.jpg"|picture_resize:150:100:'crop'} affiche une vignette ou l'image prend toute la place, du coup l'image peut être coupée. {"$img_prod_dir`$product.id_image`.jpg"|picture_resize:150:100:'dontCrop':'#FF0000'} affiche une vignette avec un bord rouge (#FF0000) Est-ce que c'est plus clair maintenant ? Share this post Link to post Share on other sites
holyknight 0 Posted June 24, 2009 Posted June 24, 2009 Oui merci Mais je cherche toujours un moyen, pour habiller d'une image un block comme catégorie ou produit par example... Share this post Link to post Share on other sites
fulviods 7 Posted May 2, 2010 Posted May 2, 2010 merci très pratique utilisé avec la contribution pour l'affichage des catégories en première page Share this post Link to post Share on other sites
Recommended Posts