diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index e7a7ddca4..a1e866cb2 100644 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -277,25 +277,6 @@ class Image extends BaseLoop } return $loopResult; -/* -#PRODUIT : identifiant du produit associé (valué si le paramètre "produit" a été indiqué) -#PRODTITRE : titre du produit associé (valué si le paramètre "produit" a été indiqué) -#PRODREF : référence du produit associé (valué si le paramètre "produit" a été indiqué) -#RUBRIQUE : identifiant de la rubrique associée (valué si le paramètre "rubrique" a été indiqué) -#RUBTITRE : titre de la rubrique associée (valué si le paramètre "rubrique" a été indiqué) -#DOSSIER : identifiant du dossier associée (valué si le paramètre "dossier" a été indiqué) -#DOSTITRE : titre du dossier associée (valué si le paramètre "dossier" a été indiqué) -#CONTENU : identifiant du contenu associée (valué si le paramètre "contenu" a été indiqué) -#CONTTITRE : titre du contenu associée (valué si le paramètre "contenu" a été indiqué) -#IMAGE : URL de l'image transformée (redimensionnée, inversée, etc. suivant les paramètres d'entrée de la boucle). -#FICHIER : URL de l'image originale -#ID : identifiant de l'image - -#TITRE : titre de l'image -#CHAPO : description courte de l'image -#DESCRIPTION : description longue de l'image -#COMPT : compteur débutant à 1. Utile pour l'utilisation de Javascript. - */ } /** diff --git a/install/faker-assets/FreeSans.ttf b/install/faker-assets/FreeSans.ttf new file mode 100644 index 000000000..9db958532 Binary files /dev/null and b/install/faker-assets/FreeSans.ttf differ diff --git a/install/faker.php b/install/faker.php index 54d5c80fc..b262a8460 100755 --- a/install/faker.php +++ b/install/faker.php @@ -4,6 +4,8 @@ use Propel\Runtime\Exception\PropelException; use Thelia\Model\CategoryImage; use Thelia\Model\FolderImage; use Thelia\Model\ContentImage; +use Imagine\Image\Color; +use Imagine\Image\Point; require __DIR__ . '/../core/bootstrap.php'; $thelia = new Thelia\Core\Thelia("dev", true); @@ -30,15 +32,38 @@ function generate_image($image, $position, $typeobj, $id) { ; // Generate images - $image_data = file_get_contents("http://placehold.it/320x200&text=Image+for+$typeobj+ID+".$id); + $imagine = new Imagine\Gd\Imagine(); + $image = $imagine->create(new Imagine\Image\Box(320,240), new Color('#E9730F')); + + $white = new Color('#FFF'); + + $font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 14, $white); + + $tbox = $font->box("THELIA"); + $image->draw()->text("THELIA", $font, new Point((320 - $tbox->getWidth()) / 2, 30)); + + $str = sprintf("%s sample image", ucfirst($typeobj)); + $tbox = $font->box($str); + $image->draw()->text($str, $font, new Point((320 - $tbox->getWidth()) / 2, 80)); + + $font = $imagine->font(__DIR__.'/faker-assets/FreeSans.ttf', 18, $white); + + $str = sprintf("%s ID %d", strtoupper($typeobj), $id); + $tbox = $font->box($str); + $image->draw()->text($str, $font, new Point((320 - $tbox->getWidth()) / 2, 180)); + + $image->draw() + ->line(new Point(0, 0), new Point(319, 0), $white) + ->line(new Point(319, 0), new Point(319, 239), $white) + ->line(new Point(319, 239), new Point(0,239), $white) + ->line(new Point(0, 239), new Point(0, 0), $white) + ; + $image_file = sprintf("%s/../local/media/images/%s/sample-image-%s.png", __DIR__, $typeobj, $id); if (! is_dir(dirname($image_file))) mkdir(dirname($image_file), 0777, true); - if ($fh = fopen($image_file, "w")) { - fwrite($fh, $image_data); - fclose($fh); - } + $image->save($image_file); } try {