@@ -31,26 +31,43 @@ public function handle(): Response
3131 $ image = new ImageManager (new Driver );
3232 $ text = wordwrap ($ this ->article ->title (), self ::CHARACTERS_PER_LINE );
3333
34- return Cache::remember (
35- 'articleSocialImage- ' .$ this ->article ->id ,
36- now ()->addDay (),
37- fn () => response (
38- $ image ->read (resource_path ('images/ ' .self ::TEMPLATE ))
39- ->text (
40- $ text ,
41- self ::TEXT_X_POSITION ,
42- self ::calculateTextYPosition ($ text ),
43- function ($ font ) {
44- $ font ->file (resource_path ('fonts/ ' .self ::FONT ));
45- $ font ->size (self ::FONT_SIZE );
46- $ font ->color (self ::TEXT_COLOUR );
47- }
48- )
49- ->toPng ()
50- )
51- ->header ('Content-Type ' , 'image/png ' )
52- ->header ('Cache-Control ' , 'max-age=86400, public ' )
53- );
34+ return response (
35+ $ image ->read (resource_path ('images/ ' .self ::TEMPLATE ))
36+ ->text (
37+ $ text ,
38+ self ::TEXT_X_POSITION ,
39+ self ::calculateTextYPosition ($ text ),
40+ function ($ font ) {
41+ $ font ->file (resource_path ('fonts/ ' .self ::FONT ));
42+ $ font ->size (self ::FONT_SIZE );
43+ $ font ->color (self ::TEXT_COLOUR );
44+ }
45+ )
46+ ->toPng ()
47+ )
48+ ->header ('Content-Type ' , 'image/png ' )
49+ ->header ('Cache-Control ' , 'max-age=86400, public ' );
50+
51+ // return Cache::remember(
52+ // 'articleSocialImage-'.$this->article->id,
53+ // now()->addDay(),
54+ // fn () => response(
55+ // $image->read(resource_path('images/'.self::TEMPLATE))
56+ // ->text(
57+ // $text,
58+ // self::TEXT_X_POSITION,
59+ // self::calculateTextYPosition($text),
60+ // function ($font) {
61+ // $font->file(resource_path('fonts/'.self::FONT));
62+ // $font->size(self::FONT_SIZE);
63+ // $font->color(self::TEXT_COLOUR);
64+ // }
65+ // )
66+ // ->toPng()
67+ // )
68+ // ->header('Content-Type', 'image/png')
69+ // ->header('Cache-Control', 'max-age=86400, public')
70+ // );
5471 }
5572
5673 private function calculateTextYPosition (string $ text ): int
0 commit comments