Skip to content

Commit

Permalink
jpeg、webpどちらのサムネも$res['thumbnail']にファイル名。webpがあるときはjpegのサムネを作らない。
Browse files Browse the repository at this point in the history
  • Loading branch information
satopian committed Nov 9, 2024
1 parent e307e82 commit 490fda0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 33 deletions.
24 changes: 13 additions & 11 deletions petitnote/functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$functions_ver=20241102;
$functions_ver=20241109;
//編集モードログアウト
function logout(){
$resno=(int)filter_input(INPUT_GET,'resno',FILTER_VALIDATE_INT);
Expand Down Expand Up @@ -322,11 +322,13 @@ function create_res($line,$options=[]){
if($hide_thumbnail){
list($w,$h)=image_reduction_display($w,$h,300,300);
}
$thumbnail_jpg = (strpos($thumbnail,'thumbnail')!==false) ? $time.'s.jpg' : false;
$thumbnail_webp = $thumbnail_jpg && (strpos($thumbnail,'thumbnail_webp')!==false) ? $time.'s.webp' : false;
$thumbnail_webp = ((strpos($thumbnail,'thumbnail_webp')!==false)) ? $time.'s.webp' : false;
$thumbnail_jpg = (!$thumbnail_webp && strpos($thumbnail,'thumbnail')!==false) ? $time.'s.jpg' : false;

$link_thumbnail= ($thumbnail_jpg || $hide_thumbnail);
$painttime = !$isset_catalog ? calcPtime($paintsec) : false;
$thumbnail_img = $thumbnail_webp ? $thumbnail_webp : $thumbnail_jpg;

$link_thumbnail= ($thumbnail_img || $hide_thumbnail);
$painttime = !$isset_catalog ? calcPtime($paintsec) : false;

$datetime = $do_not_change_posts_time ? microtime2time($first_posted_time) : microtime2time($time);
$date=$datetime ? date('y/m/d',(int)$datetime):'';
Expand All @@ -346,8 +348,7 @@ function create_res($line,$options=[]){
'com' => $com,
'url' => $url ? filter_var($url,FILTER_VALIDATE_URL) : '',
'img' => $imgfile,
'thumbnail' => $thumbnail_jpg,
'thumbnail_webp' => $thumbnail_webp,
'thumbnail' => $thumbnail_img,//webp or jpegのサムネイルのファイル名
'painttime' => $painttime ? $painttime['ja'] : '',
'painttime_en' => $painttime ? $painttime['en'] : '',
'paintsec' => $paintsec,
Expand Down Expand Up @@ -723,12 +724,13 @@ function make_thumbnail($imgfile,$time,$max_w,$max_h){
global $use_thumb;
$thumbnail='';
if($use_thumb){//スレッドの画像のサムネイルを使う時
if(thumbnail_gd::thumb(IMG_DIR,$imgfile,$time,$max_w,$max_h)){
$thumbnail='thumbnail';
}
if($thumbnail && thumbnail_gd::thumb(IMG_DIR,$imgfile,$time,$max_w,$max_h,['thumbnail_webp'=>true])){
if(thumbnail_gd::thumb(IMG_DIR,$imgfile,$time,$max_w,$max_h,['thumbnail_webp'=>true])){
$thumbnail='thumbnail_webp';
}
//webpサムネイルが作成されなかった時はjpegのサムネイルを作る
if(!$thumbnail && thumbnail_gd::thumb(IMG_DIR,$imgfile,$time,$max_w,$max_h)){
$thumbnail='thumbnail';
}
}
//カタログ用webpサムネイル
thumbnail_gd::thumb(IMG_DIR,$imgfile,$time,300,800,['webp'=>true]);
Expand Down
6 changes: 3 additions & 3 deletions petitnote/index.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
//Petit Note (c)さとぴあ @satopian 2021-2024
//1スレッド1ログファイル形式のスレッド式画像掲示板
$petit_ver='v1.56.8';
$petit_lot='lot.20241107';
$petit_ver='v1.57.0';
$petit_lot='lot.20241109';
$lang = ($http_langs = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '')
? explode( ',', $http_langs )[0] : '';
$en= (stripos($lang,'ja')!==0);
Expand All @@ -16,7 +16,7 @@
return die(__DIR__.'/functions.php'.($en ? ' does not exist.':'がありません。'));
}
require_once(__DIR__.'/functions.php');
if(!isset($functions_ver)||$functions_ver<20241102){
if(!isset($functions_ver)||$functions_ver<20241109){
return die($en?'Please update functions.php to the latest version.':'functions.phpを最新版に更新してください。');
}
check_file(__DIR__.'/misskey_note.inc.php');
Expand Down
6 changes: 0 additions & 6 deletions petitnote/template/basic/parts/before_edit_del_res_loop.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,7 @@ <h3 class="imginfo_wrap">
<div class="posted_image <?php if($res['hide_thumbnail']):?>hide_thumbnail<?php endif;?>" style="<?php if($res['w']>747):?>float:none;margin-right:0;<?php endif;?>max-width:<?=h($res['w'])?>px;max-height:<?=h($res['h'])?>px;">
<a href="src/<?=h($res['img'])?>" target="_blank" data-lightbox="<?=h($res['no'])?>_<?=h($res['time'])?>">
<?php if($res['thumbnail']):?>
<?php if(isset($res['thumbnail_webp']) && $res['thumbnail_webp']):?>
<picture><source srcset="thumbnail/<?=h($res['thumbnail_webp'])?>" type="image/webp">
<?php endif;?>
<img src="thumbnail/<?=h($res['thumbnail'])?>" alt="<?=h($res['sub'])?> by <?=h($res['name'])?>" title="<?=h($res['sub'])?> by <?=h($res['name'])?>" width="<?=h($res['w'])?>" height="<?=h($res['h'])?>">
<?php if(isset($res['thumbnail_webp']) && $res['thumbnail_webp']):?>
</picture>
<?php endif;?>
<?php else:?>
<img src="src/<?=h($res['img'])?>" alt="<?=h($res['sub'])?> by <?=h($res['name'])?>" title="<?=h($res['sub'])?> by <?=h($res['name'])?>" width="<?=h($res['w'])?>" height="<?=h($res['h'])?>">
<?php endif;?>
Expand Down
6 changes: 0 additions & 6 deletions petitnote/template/basic/parts/edit_form_res_loop.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ <h2 class="article_title">[<?= h($ress[0]['no'])?>] <?= h($ress[0]['sub'])?></h2
<div class="posted_image <?php if($res['hide_thumbnail']):?>hide_thumbnail<?php endif;?>" <?php if($res['_w']>747):?>style="float:none;margin-right:0"<?php endif;?>>
<a href="src/<?=h($res['img'])?>" target="_blank" data-lightbox="<?=h($res['no'])?>_<?=h($res['time'])?>">
<?php if($res['thumbnail']):?>
<?php if(isset($res['thumbnail_webp']) && $res['thumbnail_webp']):?>
<picture><source srcset="thumbnail/<?=h($res['thumbnail_webp'])?>" type="image/webp">
<?php endif;?>
<img src="thumbnail/<?=h($res['thumbnail'])?>" alt="<?=h($res['sub'])?> by <?=h($res['name'])?>" title="<?=h($res['sub'])?> by <?=h($res['name'])?>" width="<?=h($res['w'])?>" height="<?=h($res['h'])?>">
<?php if(isset($res['thumbnail_webp']) && $res['thumbnail_webp']):?>
</picture>
<?php endif;?>
<?php else:?>
<img src="src/<?=h($res['img'])?>" alt="<?=h($res['sub'])?> by <?=h($res['name'])?>" title="<?=h($res['sub'])?> by <?=h($res['name'])?>" width="<?=h($res['w'])?>" height="<?=h($res['h'])?>">
<?php endif;?>
Expand Down
7 changes: 0 additions & 7 deletions petitnote/template/basic/parts/threads_loop.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,7 @@ <h3 class="imginfo_wrap">
<div class="posted_image <?php if($res['hide_thumbnail']):?>hide_thumbnail<?php endif;?>" style="<?php if($res['w']>747):?>float:none;margin-right:0;<?php endif;?>max-width:<?=h($res['w'])?>px;max-height:<?=h($res['h'])?>px;">
<a href="src/<?=h($res['img'])?>" target="_blank" data-lightbox="<?php if(isset($ress[0]['find_hide_thumbnail'])&&!$ress[0]['find_hide_thumbnail']||$set_nsfw_show_hide):?><?=h($res['no'])?><?php else:?><?=h($res['no'])?>_<?=h($res['time'])?><?php endif;?>">
<?php if($res['thumbnail']):?>
<?php if(isset($res['thumbnail_webp']) && $res['thumbnail_webp']):?>
<picture><source srcset="thumbnail/<?=h($res['thumbnail_webp'])?>" type="image/webp">
<?php endif;?>
<img src="thumbnail/<?=h($res['thumbnail'])?>" alt="<?=h($res['sub'])?> by <?=h($res['name'])?>" title="<?=h($res['sub'])?> by <?=h($res['name'])?>" width="<?=h($res['w'])?>" height="<?=h($res['h'])?>" <?php if($t>4||($resmode && $i>4)):?>loading="lazy"<?php endif;?>>
<?php if(isset($res['thumbnail_webp']) && $res['thumbnail_webp']):?>
</picture>
<?php endif;?>

<?php else:?>
<img src="src/<?=h($res['img'])?>" alt="<?=h($res['sub'])?> by <?=h($res['name'])?>" title="<?=h($res['sub'])?> by <?=h($res['name'])?>" width="<?=h($res['w'])?>" height="<?=h($res['h'])?>" <?php if($t>4||($resmode && $i>4)):?>loading="lazy"<?php endif;?>>
<?php endif;?>
Expand Down

0 comments on commit 490fda0

Please sign in to comment.