From fe4db1b3e0c79a6603cd6af9b615d04e890ea884 Mon Sep 17 00:00:00 2001 From: Name Date: Wed, 16 Jun 2021 16:05:30 +0300 Subject: [PATCH] correct helper picbook --- app/api/book.php | 4 +++- app/helpers/picbook.php | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/api/book.php b/app/api/book.php index 8fc4d20..12fa4c9 100644 --- a/app/api/book.php +++ b/app/api/book.php @@ -21,7 +21,9 @@ function bookid_kuri($slug) { if (isset($book['price_id'])){ - $book['pic'] = IMGSRV."price/300x470/{$book['price_id']}.{$book['priceimg']}"; + //$book['pic'] = IMGSRV."price/300x470/{$book['price_id']}.{$book['priceimg']}"; + $book['pic'] = picbook($book, 300, 470); + $book['links']['pdf'] = SITE.'read/'.$book['pricehash']; $book['links']['text'] = SITE.'readtext/'.$book['pricehash']; $file = PDFSOURCE.$book['price_id'].'.pdf'; diff --git a/app/helpers/picbook.php b/app/helpers/picbook.php index 4a3f230..aa0c83c 100644 --- a/app/helpers/picbook.php +++ b/app/helpers/picbook.php @@ -5,6 +5,16 @@ function picbook($item, $width, $height) { - return IMGSRV.'price/'.$width.'x'.$height.'/'.$item['price_id'].'.'.$item['priceimg']; + $id = $item['price_id']; + $img = $item['priceimg']; + + if (in_array($img, array('jpg', 'jpeg', 'gif', 'png', 'JPG'))){ + $fileimg = $id . '.' . $img; + } + else + $fileimg = $img; + + + return IMGSRV.'price/'.$width.'x'.$height.'/'.$fileimg; } \ No newline at end of file