Update (seo)
Add (lqip)
This commit is contained in:
@@ -208,7 +208,9 @@ public static function handle($post)
|
||||
$yPosition += $fontSize + $padding;
|
||||
}
|
||||
|
||||
$filename = $post->slug.'-'.epoch_now_timestamp().'.jpg';
|
||||
$epoch_now_timestamp = epoch_now_timestamp();
|
||||
|
||||
$filename = $post->slug.'-'.$epoch_now_timestamp.'.jpg';
|
||||
|
||||
$ok = OSSUploader::uploadFile('r2', 'post_images/', $filename, (string) $canvas->stream('jpeg'));
|
||||
|
||||
@@ -216,18 +218,20 @@ public static function handle($post)
|
||||
// Clone the main image for LQIP version
|
||||
$lqipImage = clone $canvas;
|
||||
|
||||
// Create the LQIP version of the image
|
||||
$lqipImage->fit(10, 10, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
// Apply blur
|
||||
$lqipImage->blur(5); // Adjust to the desired blur level
|
||||
|
||||
$lqipImage->encode('jpg', 5);
|
||||
// Pixelate the image
|
||||
$lqipImage->pixelate(30); // Adjust this value based on the desired pixelation level
|
||||
|
||||
// Encode the image to a low-quality JPG
|
||||
$lqipImage->encode('webp', 5);
|
||||
|
||||
// LQIP filename
|
||||
$lqip_filename = $post->slug.'-'.epoch_now_timestamp().'_lqip.jpg';
|
||||
$lqip_filename = $post->slug.'-'.$epoch_now_timestamp.'_lqip.webp';
|
||||
|
||||
// Upload the LQIP version using OSSUploader
|
||||
$lqip_ok = OSSUploader::uploadFile('r2', 'post_images/', $lqip_filename, (string) $lqipImage->stream('jpeg'));
|
||||
$lqip_ok = OSSUploader::uploadFile('r2', 'post_images/', $lqip_filename, (string) $lqipImage->stream('webp'));
|
||||
|
||||
if ($ok && $lqip_ok) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user